Open olikraus opened 9 years ago
Not sure how to support this as it is difficult for me to test. Precondition is to use
different chip signal lines for both devices.
Is it Teensy 3.x? Currently there is no HW support for Teensy 3.x
Reported by olikraus
on 2014-04-22 17:08:34
I am using different CS pins. I understand that is it hard to test and not supported.
Maybe you can point me to the function I can try and work on to get it to work. I had
it working with the Adafruit lib modified for hardware SPI.
I am working with a PCB so currently can't make any changes to hardware till the next
hardware revision.
Thanks for anything you can help with.
Reported by blackspartan117
on 2014-04-22 17:15:29
you need to implement your own "com" procedure. Someone else had done a nice description
on this:
http://blog.bastelhalde.de/?p=759
Reported by olikraus
on 2014-04-22 17:36:33
Awesome, I will try and get it to work then. Let you know how it goes.
Reported by blackspartan117
on 2014-04-22 19:27:01
Does the Arduino version of the library support adding your own stub or is it only the
ARM version? Do you think the ARM version will still working with the Arduino IDE?
I am trying to keep using the Arduino IDE so the device is easily hackable by others.
Thanks.
Reported by blackspartan117
on 2014-04-23 04:39:31
The arm version does not include the C++ interface. So it might be difficult for the
Arduino users.
On the other side, there is a generic C++ constructor, which allows you to specify
the com interface:
U8GLIB(u8g_dev_t *dev, u8g_com_fnptr com_fn)
Then, for the Arduino Users, this should be:
U8GLIB(u8g_dev_ssd1306_128x64_2x_sw_spi, my_com_fn)
where "my_com_fn" has to be supplied by you as described in the mentioned tutorial.
Another good thing by using the arduino variant is, that you do not need to provide
the delay procedures (these are already part of the arduino variant).
Reported by olikraus
on 2014-04-23 04:51:47
Okay I have this mostly setup.
How do I specify the DC and reset pins, in the com interface?
So something like this?
U8GLIB(u8g_dev_ssd1306_128x64_2x_hw_spi, u8g_com_hw_spi_fn);
or is it sw_spi even if using hardware?
Also where do you define the object name? In my case display.
Reported by blackspartan117
on 2014-04-23 05:28:03
> How do I specify the DC and reset pins, in the com interface?
Your com procedure has to deal with these lines, so if you use fixed pins, then just
use fixed bins in your com callback procedure. No need to specify them on the constructor.
> or is it sw_spi even if using hardware?
The device type does not matter. You can use u8g_dev_ssd1306_128x64_2x_hw_spi or u8g_dev_ssd1306_128x64_2x_sw_spi.
Only your com procedure matters.
> Also where do you define the object name? In my case display.
Should be this:
U8GLIB display(u8g_dev_ssd1306_128x64_2x_hw_spi, u8g_com_hw_spi_fn);
Reported by olikraus
on 2014-04-23 09:32:12
Thanks so much!!! I got it to work!! Now I just need to clean it up and make it more
flexiable so anyone can use it.
I will post on github once its ready.
Actually all it does is uses the Arduino SPI library which is installed by Teensy software
so the same functions work. Might be easy to get it to work on the core library.
This post helped as well
http://forum.pjrc.com/threads/24357-u8glib-now-has-an-ARM-variant?p=46427
And looked the Adafruit library as well.
So does your library use the Arduino SPI library or direct port\registers?
Thanks.
Reported by blackspartan117
on 2014-04-24 04:09:30
Great.
Regarding HW SPI: I decided to to write directly to the uC registers. Now i know it
had been a wrong devision. In ucglib (another more recent lib from me) i am using SPI
fronm the IDE to be more portable.
Reported by olikraus
on 2014-04-24 04:42:34
No problem, it was a good exercise, ;). Cool, I will have to check out the ucglib library.
I have a Color LCD here. If you want I can test for you. Its a 2.2in LCD with the iL9341
driver. Right now its connected to a Arduino UNO. I haven't had a chance to really
play with it.
Reported by blackspartan117
on 2014-04-24 05:06:35
Yes, iL9341 is supported and standard SPI.h should work. In fact i learned a lot from
U8glib and did a major cleanup of the internal interfaces for Ucglib.
Reported by olikraus
on 2014-04-24 08:08:34
Ucglib is available here for download:
http://forum.arduino.cc/index.php?topic=222327.0
Or drop me an e-mail for the latest release.
Reported by olikraus
on 2014-04-24 08:11:49
u8glib 2.x should use the Arduino SPI library instead of the AVR sub system.
will put this into "Milestone-Collect"
However i did not check if this request already exists.
Reported by olikraus
on 2014-06-16 19:20:51
Any updates on the status of hardware SPI for the Teensy 3.0/3.1?
Reported by lucas.berezy
on 2014-10-03 22:15:12
It works great with the code stub that uses the Arduino\Teensy SPI library.
Reported by blackspartan117
on 2014-10-03 22:18:32
Which code stub exactly, have you published any of your code to github yet (if not,
could you)?
I'm currently trying to get an eBay SSD1306 128x64 OLED working with the Teensy 3.1,
but to no avail. I've got the display working on an Uno with u8glib, so I know the
display works. Not sure if it's a voltage level thing (shouldn't be) or SPI speed thing.
Thanks
Reported by lucas.berezy
on 2014-10-05 23:38:40
I'm currently using NHD-3.12-25664UMB3 Controller: SSD1322, 256x64 pixels BLUE graphic
OLED display by New Haven with HW SPI on Teensy 3.0 in 16bit mode.
About 50 FPS ):
Thanks to Hoss from pjrc Teensy forum, he was able to adapt the Teensy 3 hardware SPI
code from Adafruit_ST7735 driver to work in U8G.
Here is the forum link:
page 3,post #52
http://forum.pjrc.com/threads/23445-Teensy-3-0-and-u8glib/page3
complete U8glib Arduino library folder containing U8G version 1.15 for Arduino/Teensy3.x
including Hoss tweaks.
link:
http://forum.pjrc.com/attachment.php?attachmentid=2033&d=1400770307
IMPORTANT NOTE: Needed for HW Spi on teensy 3.x with Hoss U8G modify Library, in you're
code.
#include <SPI.h>
Chris O.
Reported by dieselko@netzero.net
on 2014-10-06 03:52:03
Thank you for the update.
Reported by olikraus
on 2014-10-06 18:52:02
Hi, sorry for late reply.
Here is my add-on that I use with the Teensy 3.1
https://github.com/FriedCircuits/Ug8lib_Teensy
Works well since it is using the Teensy SPI library and therefore hardware SPI. Should
work for any SPI display.
Remember most displays are 3.3v buy Teensy can handle 3.3v and is mostly 5v tolerant.
Reported by blackspartan117
on 2014-10-06 21:23:57
Hello Olivier,
About your last post of this thread, I there a way to implement directly the Transactional SPI for Teensy directly inside U8Glib instead of doing it with U8Glib_Teensy ? I need to keep the U8Glib structure, because I'm trying to implement inside an another library (ArduinoMenu) the U8Glib to draw the menu on HW_SPI display, and it is running on Teensy 3.2.
Thanks for you reply. Christophe
I rewrote u8glib and renamed everything to u8g2. This new version (so to say u8glib v2) uses SPI.h only.
Repo: https://github.com/olikraus/u8g2
U8g2 also comes with some simple menus... https://github.com/olikraus/u8g2/wiki/u8g2reference#userinterfaceinputvalue
Hello Olivier,
Thanks for your quick reply, and the v2 seems to have great improvements ! Can you tell me if U8G2 run on Teensy 3.x and if you plan to include SSD1322 from NHD which is actually the one I'm using. I noticed that Chris O. made a lot of improvements in this library to transactional SPI, are they included in the new version ? At this time I'm using u8g_teensy.cpp and the prototype looks like this :
// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
U8GLIB _U8G(&u8g_dev_ssd1322_nhd31oled_2x_gr_hw_spi, u8g_com_hw_spi_fn);
Finally, the Menu inputs are a great idea, but is there a way to use ClickEncoder Library to use quadrature encoder instead of buttons inputs ? Any way to implements that in the begin() declaration ?
#include <ClickEncoder.h>
/* Quad Encoder */
#define CK_ENC 2 // ISR capable input
#define DT_ENC 7
#define SW_ENC 6
ClickEncoder Encoder(DT_ENC, CK_ENC, SW_ENC, 4, LOW);
Thanks
Thanks for your answers, so I will put an issue for the SSD1322 for which I can perform tests and debugs. Understood for the menu and encoder, I will develop my own solution ;)
I am trying to use ucgIib with Teensy 3.6 and was able to compile by making the following changes ucg.h
//#ifdef __AVR__
volatile uint8_t *data_port[UCG_PIN_COUNT];
uint8_t data_mask[UCG_PIN_COUNT];
//#endif
Ucglib.h
class Ucglib4WireHWSPI : public Ucglib
{
public:
Ucglib4WireHWSPI(ucg_dev_fnptr dev, ucg_dev_fnptr ext, uint8_t cd, uint8_t cs = UCG_PIN_VAL_NONE, uint8_t reset = UCG_PIN_VAL_NONE)
{ init(); dev_cb = dev; ext_cb = ext;
ucg.pin_list[UCG_PIN_RST] = reset;
ucg.pin_list[UCG_PIN_CD] = cd;
ucg.pin_list[UCG_PIN_CS] = cs;
// #ifdef __AVR__
ucg.data_port[UCG_PIN_RST] = portOutputRegister(digitalPinToPort(reset));
ucg.data_mask[UCG_PIN_RST] = digitalPinToBitMask(reset);
ucg.data_port[UCG_PIN_CD] = portOutputRegister(digitalPinToPort(cd));
ucg.data_mask[UCG_PIN_CD] = digitalPinToBitMask(cd);
ucg.data_port[UCG_PIN_CS] = portOutputRegister(digitalPinToPort(cs));
ucg.data_mask[UCG_PIN_CS] = digitalPinToBitMask(cs);
// #endif
}
void begin(uint8_t is_transparent);
};
Ucglib.cpp
#if defined(KINETISK)
static volatile uint8_t *u8g_data_port[9];
static uint8_t u8g_data_mask[9];
#elif defined(__PIC32MX) || defined(__arm__) || defined(ESP8266)
/* CHIPKIT PIC32 */
static volatile uint32_t *u8g_data_port[9];
static uint32_t u8g_data_mask[9];
#else
static volatile uint8_t *u8g_data_port[9];
static uint8_t u8g_data_mask[9];
#endif
#if defined(__arm__)
__attribute__( ( always_inline ) ) static inline void __NOP(void)
{
__asm volatile ("nop");
}
#endif
static void ucg_com_arduino_send_8bit(ucg_t *ucg, uint8_t data)
{
int i;
#if defined(__arm__)
__NOP;
I tested the library using HelloWorld.ino
and make the following changes
Ucglib_SSD1351_18x128x128_HWSPI ucg(/cd=/ 15 , /cs=/ 10, /reset=/ 16);
I connected Adafruit 1.5" OLED (SSD1351):
OLED | TEENSY 3.6 |
---|---|
GND | GND |
Vin | Vin |
3Vo | 3.3V |
OLEDCS | 10 |
RESET | 16 |
DC | 15 |
SCK | 14 |
MOSI | 11 |
However, the OLED screen remained blank.
I think this is the wrong project... last comment should be a new issue in ucglib
even I do not know what he means. mad_device_sd is part of my mk2tklib if I remember correctly. Maybe it works if you install m2tk.
I'll try it. thanks Is there are other solutions to deal with sw spi and sd except "u8g2" @olikraus
u8g2 does not deal with sd drives.
when i use "u8g2", i can't read sd ,even initialize sd card. what should i do?
I do not know, u8g2 is not responsible for reading from SD. I have never heard about any conflicts between u8g2 and SD libraries.
Ok, there is one point: If pins are shared, then you (usually) must use hardware SPI for u8g2 (HW SPI). For SPI the same is true as for I2C: https://github.com/olikraus/u8g2/blob/master/doc/faq.txt#L9
But even this is not u8g2 specific. It is a general topic.
it must be my mistake. Thank a lot.
@olikraus Hello, i installed "m2tklib_arduino_u8g_1.08", but i still get the error"'mas_device_sd' was not declared in this scope" then i add "#include mas.h", i get the error "no such file or directory'mas.h'", but i can find the mas.h in m2tklib/utility Any suggestion? Thanks.
maybe you need to write #include "utility/mas.h"
You are right. Thanks a lot.
Originally reported on Google Code with ID 256
Reported by
blackspartan117
on 2014-04-22 02:32:03