the video code uses sin and cos like picaxe. it don't do pi or floating point math only long vars like picaxe doesn't.Things are getting more clear with every post of your help, thanks.
To put all info sofar in perspective(please correct me if I'm wrong)...
* Didn't now the diversity of SSD1306 displays! I thought that sda+scl always means I2C in their communications. So I will order a new 4pins display.
* But still SSD1306 displays are essentional parts that I (and a lot of people) can use in many existing and future (low power, compact and lightweight) projects.
* Even to replace project displays for instance, about 5 years ago, where I used a red 4 digits LED DOT matrix for heating temperature in °C and very short error messages with running text.
* So while designing new projects and upgrading old ones with a SSD1306 display it could sometimes be easier to just add another PIC(axe) or AVR as a display driver. I did that with a previous project where I used the picaxe 20X2 driver by @marks to drive a 4x20 LCD, and works great. Less rerouting of the old pcb by just adding instead of replacing with a bigger chip.
* Therefore for me the R&D of the 08M2, 28X2 or non-picaxe chips to drive the SSD1306 display is desirable. (And this thread can help others)
* Even with the 08M2 I at least like to see what is accomplished.
* With new projects though @stan74 has a point saying...
* Also, besides the slow grahics, the refresh rate of characters is slower with a picaxe.
* But how much faster does a graphic or text needs to be depends on the project where often the PICAXE is fast enough.
* Because of the PICAXE catching BASIC instead of C+, I love to use it as overall master controller.
* External cheaper and faster alternative (display or other) drivers with an Microchip or AVR (with LIB) eventually is also desirable on other forums. The video @stan74 "SSD1306 analogue voltmeter" is impressive!
* Running all (controller and driver code) within one chip (28X2 or non-picaxe) is an good option that I'm trying. (but also where to maybe waste many unused I/O's).
Took me some time to structural write my philosophy on this, but glad to have cleared my mind.
more not picaxe but when I was really into picaxe stuff like this was gold.the video code uses sin and cos like picaxe. it don't do pi or floating point math only long vars like picaxe doesn't.
I got trig working better since this.
;analogue 5V voltmeter and DVM - OK 13-7-17
#chip mega328p, 16
#define HI2C_BAUD_RATE 400
#define GLCD_TYPE GLCD_TYPE_SSD1306
#define GLCD_I2C_Address 0x78
#define ADSpeed LowSpeed
dir portc.0 in
dim radius,xcentre,ycentre,xend,old_xend,yend,old_yend as byte
dim angle,old_angle,adcval as word
dim volts as string * 4
for radius=144 to 141
GLCDDrawChar (5,40,asc("0")):GLCDDrawChar (115,40,asc("5"))
if adcval<10 then
if adcval<100 then
old_xend = xcentre + radius * sin (old_angle)/255
old_yend = ycentre - radius * cos (old_angle)/255
xend = xcentre + radius * sin (angle)/255
yend = ycentre - radius * cos (angle)/255
if old_angle<>angle then ;-- update screen if volts has changed
; erase old needle
; draw V
line (55,22,63,38):line (63,38,71,22)
; print new voltage
GLCDPrint (50,10,volts,1) ;new-print Voltage
; draw new needle
; wait 20 ms
xend = 63 + radius * sin (angle)/255
yend = 58 - radius * cos (angle)/255
for angle= 296 to 359
for angle= 0 to 63
if angle>127 then
* Thus achieving better archiving of threads and forums without breaking picaxe rules.I would simply replicate the Nextion command set. No point in reinventing the wheel. Then, you can use the Nextion library to drive the unit."
You surprise me! Thought I made no sense.Yes, I understand and agree with nearly all that you say in your philiosophy.
Perhaps for the SSD1306 a driver can be made like the 20X2 LCD driver code from @marks where the user(also kids) can quickly implement a small display and start from scratch programming only the master controller over serial and/or I2C.But perhaps I should quote from my introduction to my ASCII / SSD1306 / 08M2 thread:
" The program was intended as a "core" or "preamble" for further development, ...... The code size is about 1400 bytes, so there is space for around another 500 bytes, even with an 08M2; or some/most of the code might be removed in a final application. ".
I slightly regret posting it in the "Finished / Video Projects" because it was really intended as a "Code Snippet" (where I usually post my programs) rather like a "Library" function with Arduino. The user still needs to understand what the "Library" function does and write their own "Sketch" program.
Maybe the code also could be added as a complete (long) attachment too, instead of minimizing it so it could fit in the thread "</>code" window.PICaxe doesn't normally need or use "Include" files (Hooray !), so Library and Sketch are all together, but for that SSD1306 thread the "Sketch" is basically:
which shows how the "tree" function can be used. Of course a few more lines are needed to initialise the system, etc. and more "Library" functions are available (for example "Clear Memory" and "Double-Height").Code:
; WRITE FONT TO OLED: for index = 32 to 127 char = index call tree hi2cout addr,(0) ; Inter-character gap next
Just to be sure...But it does seem that you need to be very careful about the specification of those OLED displays. Not only are there different I2C and SPI versions, but some use different control Integrated Circuits (i.e. NOT SSD1306); some are "compatible" but not all !
I hope to discuss things with you on the gcb forum where talking about picaxe or arduino code is Not a problem.@stan74, thanks for all "other basic" code and info that I really appriciate!
* I can't explore "other basic" code for not owning an arduino yet and in the past days I'm researching(with my criteria wish-list) which to buy and contact on the gcb-forum as user "Haroen".
I like to take that R&D of this forum to gcb where especially complicated bigger (touch) "graphic" displays(picaxe then to slow) will be my focus with excisting working gcb code (maybe as driver only).
* Thus achieving better archiving of threads and forums without breaking picaxe rules.
Just to save time I also want to order the 128x64 SSD1306 display too with pins for I2C.
Yes, that display looks correct; my software can also drive the 64 x 128 pixels I2C display (and it should give double-Height if an external EPROM or RAM is available), but some of the numbers (e.g. the initialisation) must be changed. There are a few other threads on the forum which show the configuration for 64 x 128. That's why a "single" program is not practical; there are many "options" that must be chosen by the user/programmer, for example:
That's almost exactly what I've done, although #DEFINEs (at the top of the program) are generally better. But there can be "too many" as happened for my project Post # 32 HERE. Also I "dislike" forum .BAS files, because they must be downloaded to my hard drive and then opened up in the PE.Couldn't we make just one sourcecode SSD1306.bas where all options are available and (de-)selecting is done by (un-)comment?
Otherwise select a picaxe with larger RAM and/or add an EEPROM.