We will probably have to adapt the library but do wire it up and when the pixels don't do what you expect... let me know.
GLCDCLS will work..but, I would be trying box 0,0,159,79. if box fails then we will have to mod the unit. A very simple change of you have it all wired up.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
;Defines (Constants)
#define SPI_HardwareSPI 'comment this out to make into Software SPI but, you may have to change clock lines
#define GLCD_TYPE GLCD_TYPE_ST7735
#define DEFAULT_GLCDBACKGROUND 0xF800 ;0x67F0
#define ST7735TABCOLOR ST7735_MINI160x80
#defineGLCD_WIDTH160#defineGLCD_HEIGHT80
'Pin mappings for ST7735
#define GLCD_DC portE.2 ; Data/Command select Purple Wire
#define GLCD_CS portB.2 ; /CS Chip select White
#define GLCD_RESET portC.6
#define GLCD_DI portB.0 ; SPI SDI (MISO) Not used by this display
#define GLCD_DO portC.7 ; SPI SDO (MOSI) Blue
#define GLCD_SCK portB.1 ; SPI SCK Green
Dir GLCD_DC Out
Dir GLCD_CS Out
Dir GLCD_RESET Out
Dir GLCD_DI In
Dir GLCD_DO Out
Dir GLCD_SCK Out
GLCD_CS = 0
GLCD_DC = 0 ;Command = 0 Data = 1 I tried both 0 and 1 but saw no change in GLCD display
GLCDCLS TFT_BLUE
box 0, 0, 159, 79
Goto Do_Again
On my O'Scope, I see the GLCD_CS transistion from 1 to 0 and back to 1 but there are no clock pulses or data pulses. The display has the backlight on and does not change from a white background.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You do not need all the CS tests, GLCDCLS etc etc etc. The setup handled in the library. SPIMode is calculate, Run the chip from the internal OSC so that we can diag the basics.
This is intended to draw a box using the minimum code. I am assuming the ports/data lines are connected. Test this please. Exactly what happens on the GLCD?
;Chip Settings
#chip18F4550
#include<glcd.h>' let us us software SPI to rule out HW SPI issues.' #define SPI_HardwareSPI 'commentthisouttomakeintoSoftwareSPIbut, youmayhavetochangeclocklines
#defineGLCD_TYPEGLCD_TYPE_ST7735
#defineGLCD_WIDTH160
#defineGLCD_HEIGHT80'Pin mappings for ST7735
#defineGLCD_DCportE.2; Data/Command select Purple Wire
#defineGLCD_CSportB.2; /CS Chip select White
#defineGLCD_RESETportC.6
#defineGLCD_DIportB.0; SPI SDI (MISO) Not used by this display
#defineGLCD_DOportC.7; SPI SDO (MOSI) Blue
#defineGLCD_SCKportB.1; SPI SCK Greenbox0, 0, 10, 10DoLoop
Last edit: Anobium 2019-09-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The code posted above produces a white box on the display.
So, this was my approach.
Took stock demo and test in the test rig. This was a 18F47K42. So, this proves the demo works.
Took stock demo created a standalone rig. Again, using a 18F47K42. So, this proves the standalone rig works.
Change the ports of the stock demo to your ports. The stock demo uses software SPI. This ran the stock demo, and, changing the connections to match.
Changed to the code below for the K42. Worked with a white box on the display.
Change the chip to the 18F4550. Worked with white box on the display.
This is not fast, but, this is prove things. Then, we can sort the frequency.
Test code.
;Chip Settings
#chip18F4550
#include<glcd.h>' let us us software SPI to rule out HW SPI issues.' #define SPI_HardwareSPI 'commentthisouttomakeintoSoftwareSPIbut, youmayhavetochangeclocklines
#defineGLCD_TYPEGLCD_TYPE_ST7735
#defineGLCD_WIDTH160
#defineGLCD_HEIGHT80'Pin mappings for ST7735
#defineGLCD_DCportE.2; Data/Command select Purple Wire
#defineGLCD_CSportB.2; /CS Chip select White
#defineGLCD_RESETportC.6
#defineGLCD_DIportB.0; SPI SDI (MISO) Not used by this display
#defineGLCD_DOportC.7; SPI SDO (MOSI) Blue
#defineGLCD_SCKportB.1; SPI SCK Greenbox0, 0, 10, 10DoLoop
Note. The COLORtab only affect the offset position of the display nothing really functional.
So, check the connections - test.
And, I have attached my HEX. Could be something in version of toolchain.... maybe.
Then, post the datasheet for the GCLD. Have you spotted that the INIT is different?
By RESET I assume you mean : #define GLCD_RESET portC.6
This goes low for about 750 usec and then about 4.7 seconds later I see the clock pulses. The Data pulses start at about 6.4 seconds after the RESET pulse.
But the GLCD is the same as before.
I am using the code you posted.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just found the datasheet. The product you have is an ST7735R not ST7735.
The datasheet for the ST7735 URL is in the Help file.
Differences between the two are RGBSET (code 0x2D) which is not supported in the current driver.
So, I want you to port this to your chip. We need to know the parameters for the GLCD. C:\GCB@Syn\GreatCowBasic\Demos\glcd_solutions\glcd_discovery_for_mcufriend_devices\glcd_discovery_spi_data.gcb
This program will show you on the serial terminal lots of parameters - can we please confirm RDID1, RDID2 and RDID3 by porting the code above.
Or, send me a GLCD to sort.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
And, I just found that these MAY only work at 8mhz. So, slow the clock to the default and then try even slow frequencies... this may be a red herring but try slow frequencies.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The differences are many Power4, Power5, MADCTL, CASET, GMCTRP1 and GMCTRP2.
I can have a go at providing you a new INIT but it will be my Tuesday morning (London) time. It will not take more than 30 mins to write a new init and it should work.
:-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here we go. I have never done this before. Writing a remote GLCD library.
Baseline code. We will keep it the same but note the change to the GLCD_TYPE.
;Chip Settings for 48mhz using a 20 MHz crystal
#chip18F4550, 48
#configFOSC=HSPLL_HS, PLLDIV=5, CPUDIV=OSC1_PLL2, MCLRE=ON
#include<glcd.h>
#defineGLCD_TYPEGLCD_TYPE_ST7735R' let us us software SPI to rule out HW SPI issues. We will test HW SPI later.' #define SPI_HardwareSPI 'commentthisouttomakeintoSoftwareSPIbut, youmayhavetochangeclocklines'Pin mappings for ST7735R
#defineGLCD_DCportE.2; Data/Command select Purple Wire
#defineGLCD_CSportB.2; /CS Chip select White
#defineGLCD_RESETportC.6
#defineGLCD_DIportB.0; SPI SDI (MISO) Not used by this display
#defineGLCD_DOportC.7; SPI SDO (MOSI) Blue
#defineGLCD_SCKportB.1; SPI SCK Greenbox0, 0, 20, 20DoLoop
I have added a new type of GLCD the ST7735R. This has a different size and different init cycle but I am reusing as much as I can from the ST7735 library.
I tried both glcd_discovery_spi_data.gcb and New91.gcb with the 3 new glcd.h include files.
I assumed that I should use this #define GLCD_TYPE GLCD_TYPE_ST7735R
I get the following warning:
'>>> WARNINGs / ERRORs reported by Great Cow BASIC (if Syntax Error, doubleclick on the errormessage below) <<<
'glcd.h (206): Warning: Cannot find C:\GCB@Syn5\GreatCowBasic\include\glcd_UC1601.h
I get the same results as before - the GLCD display does not change.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
RESOLVED: NEW CAPABILITY ADDED TO GLCD DRIVER SUPPORT
EDITED - JUMP To https://sourceforge.net/p/gcbasic/discussion/579126/thread/c0adbef6f9/#46ab/f797
Does ST7735.h and GLCD.h support the SPI protocol? If so, can it be made to work with a 160 x 80 Mini TFT display?
Last edit: Anobium 2019-11-10
Thanks! I'll try this.
We will probably have to adapt the library but do wire it up and when the pixels don't do what you expect... let me know.
GLCDCLS will work..but, I would be trying box 0,0,159,79. if box fails then we will have to mod the unit. A very simple change of you have it all wired up.
I'm using this GLCD
'Adafruit Mini TFT Feather Wing 160 x 80
'https://learn.adafruit.com/adafruit-mini-tft-featherwing
Here is my code:
;Chip Settings
#chip 18F4550,48
#config PLLDIV=1, CPUDIV=OSC1_PLL2, OSC=HSPLL_HS, LVP=OFF, MCLRE=ON
;Defines (Constants)
#define SPI_HardwareSPI 'comment this out to make into Software SPI but, you may have to change clock lines
#define GLCD_TYPE GLCD_TYPE_ST7735
#define DEFAULT_GLCDBACKGROUND 0xF800 ;0x67F0
#define ST7735TABCOLOR ST7735_MINI160x80
'Pin mappings for ST7735
#define GLCD_DC portE.2 ; Data/Command select Purple Wire
#define GLCD_CS portB.2 ; /CS Chip select White
#define GLCD_RESET portC.6
#define GLCD_DI portB.0 ; SPI SDI (MISO) Not used by this display
#define GLCD_DO portC.7 ; SPI SDO (MOSI) Blue
#define GLCD_SCK portB.1 ; SPI SCK Green
Dir GLCD_DC Out
Dir GLCD_CS Out
Dir GLCD_RESET Out
Dir GLCD_DI In
Dir GLCD_DO Out
Dir GLCD_SCK Out
SPIMode ( Master, SPI_CPOL_0 + SPI_CPHA_0 )
'
wait 100 ms
Do_Again:
GLCD_CS = 1
wait 1 s
GLCD_CS = 0
GLCD_DC = 0 ;Command = 0 Data = 1 I tried both 0 and 1 but saw no change in GLCD display
GLCDCLS TFT_BLUE
box 0, 0, 159, 79
Goto Do_Again
On my O'Scope, I see the GLCD_CS transistion from 1 to 0 and back to 1 but there are no clock pulses or data pulses. The display has the backlight on and does not change from a white background.
Cut the code down to diagnose.
You do not need all the CS tests, GLCDCLS etc etc etc. The setup handled in the library. SPIMode is calculate, Run the chip from the internal OSC so that we can diag the basics.
This is intended to draw a box using the minimum code. I am assuming the ports/data lines are connected. Test this please. Exactly what happens on the GLCD?
Last edit: Anobium 2019-09-08
Yes, the port data lines are connected.
On the O'Scope I see clock and data pulses but the display is the same as before.
Ok. we have a baseline. tomorrow, I will put up a test rig.
Check back tomorrow.
Last edit: Anobium 2019-09-09
The code posted above produces a white box on the display.
So, this was my approach.
This is not fast, but, this is prove things. Then, we can sort the frequency.
Test code.
Note. The COLORtab only affect the offset position of the display nothing really functional.
So, check the connections - test.
And, I have attached my HEX. Could be something in version of toolchain.... maybe.
Then, post the datasheet for the GCLD. Have you spotted that the INIT is different?
Test and let me know the results.
I then added the config to get 48mhz, work with the white box. Then, created new demo for 4550 with the stock demo. See attachment.
So, is the GLCD totally different?
Then, I just remember. I should check Hardware SPI.
New demo posted. See https://github.com/Anobium/Great-Cow-BASIC-Demonstration-Sources/blob/master/GLCD_Solutions/GLCD_Simple_Demonstration_Solutions/glcd_simple_demonstation_18f4550_for_st7735.gcb
This uses the ports as specified in the 18f4550 post in this threads, so, we now know the Hardware and Software SPI works for a specific ST7735 GCLD.
On my O'Scope I see the Clock, Data, and CS pulses so the 18F4550 is sending the data.
The GLCD remains a blank screen with a white background and the backlight on, i.e. the GLCD is not responding.
No RESET? Very important.
Are you test the code I posted?
By RESET I assume you mean : #define GLCD_RESET portC.6
This goes low for about 750 usec and then about 4.7 seconds later I see the clock pulses. The Data pulses start at about 6.4 seconds after the RESET pulse.
But the GLCD is the same as before.
I am using the code you posted.
Datasheet please and code that is meant to work with an Arduino.
Are you UK based? Send me a private message if the answer concerns you. :-)
I just found the datasheet. The product you have is an ST7735R not ST7735.
The datasheet for the ST7735 URL is in the Help file.
Differences between the two are RGBSET (code 0x2D) which is not supported in the current driver.
So, I want you to port this to your chip. We need to know the parameters for the GLCD. C:\GCB@Syn\GreatCowBasic\Demos\glcd_solutions\glcd_discovery_for_mcufriend_devices\glcd_discovery_spi_data.gcb
This program will show you on the serial terminal lots of parameters - can we please confirm RDID1, RDID2 and RDID3 by porting the code above.
Or, send me a GLCD to sort.
And, I just found that these MAY only work at 8mhz. So, slow the clock to the default and then try even slow frequencies... this may be a red herring but try slow frequencies.
and, then, this is most informative. Python init code.
Last edit: Anobium 2019-09-09
Ok. I can port the INIT.
The differences are many Power4, Power5, MADCTL, CASET, GMCTRP1 and GMCTRP2.
I can have a go at providing you a new INIT but it will be my Tuesday morning (London) time. It will not take more than 30 mins to write a new init and it should work.
:-)
I tried C:\GCB@Syn\GreatCowBasic\Demos\glcd_solutions\glcd_discovery_for_mcufriend_devices\glcd_discovery_spi_data.gcb
I removed this line from the code: #include <uno_mega328p.h>. I don't know the equivalent file for th 18F4550.</uno_mega328p.h>
I went down to 4 MHz and ran the program.
At the start I see:
Read Registers on GLCD device
controllers with an SPI interface
reg(0x0000) FF FF FF FF FF FF FF f.k
reg(0x0001) FF FF FF FF FF FF FF f.k
reg(0x0002) FF FF FF FF FF FF FF f.k
reg(0x0003) FF FF FF FF FF FF FF f.k
All the regiaters read the same as the above.
At the end I see:
reg(0x00FC) FF FF FF FF FF FF FF f.k
reg(0x00FD) FF FF FF FF FF FF FF f.k
reg(0x00FE) FF FF FF FF FF FF FF f.k
reg(0x00FF) FF FF FF FF FF FF FF f.k
Examining :
Read : GLCD Device ID = 0x0000
Controller : unknown GLCD
Completed :
I saw nothing regarding RDID1, RDID2 and RDID3
Post the code. I will try here. That looks like it is not communicating.
Here' my code
ok. Check back tomorrow. I will try to resolve.
Here we go. I have never done this before. Writing a remote GLCD library.
Baseline code. We will keep it the same but note the change to the GLCD_TYPE.
I have added a new type of GLCD the ST7735R. This has a different size and different init cycle but I am reusing as much as I can from the ST7735 library.
Download the library from here: https://github.com/Anobium/Great-Cow-BASIC-Library-Development/tree/master/ST7735R You will see a ZIP file. Download. Backup existing GLCD files, and then replace with the contents of the ZIP.
We are using Software SPI to keep things simple. And, this does not test/confirm colors. We will do this later.
Test with the program above I cannot test... as my ST7735 not longer works with the new library... fancy that! If I have made errors then be patient.
:-)
Last edit: Anobium 2019-09-10
I tried both glcd_discovery_spi_data.gcb and New91.gcb with the 3 new glcd.h include files.
I assumed that I should use this #define GLCD_TYPE GLCD_TYPE_ST7735R
I get the following warning:
'>>> WARNINGs / ERRORs reported by Great Cow BASIC (if Syntax Error, doubleclick on the errormessage below) <<<
'glcd.h (206): Warning: Cannot find C:\GCB@Syn5\GreatCowBasic\include\glcd_UC1601.h
I get the same results as before - the GLCD display does not change.