|
|
View previous topic :: View next topic |
Author |
Message |
jamalavedra
Joined: 25 Oct 2016 Posts: 62
|
GLCD initialization problem ST7565 |
Posted: Wed Nov 16, 2016 5:46 am |
|
|
Hi there;
I have been trying to use my GLCD display http://es.rs-online.com/webdocs/1384/0900766b8138414b.pdf with a PIC18f2685 but i haven't figured out why the display doesn't initialize. Despite that, when I give voltage to the display nothing happens but right after I turn it off it displays random lines.
My PIN voltages are the following:
Pin 21: 7.58V
Pin 22: 6.75V
Pin 23: 5.90V
Pin 24: 1.703V
Pin 25: 0.853V
Pin 26: 0V
Pin 27: 1.642V
Pin 28: 7.87V
Pin 29: 4.77V
Pin 30: 1.644V
Pin 31: 10.96V
Pin 32: 12.47V
Pin 33: 0V
Pin 34: 3.3V
Pin 35: 3.3V
Pin 36: 0V and variating with every pulse
Pin 37: 0V and variating with every clock pulse
Pin 38: 3.3V
Pin 39: 3.3V
Pin 40: 3.3V
string.h
Code deleted by Forum Moderator.
stddef.h
Code deleted by Forum Moderator.
++++++++++++++++++
Code deleted.
Reason: Forum rule #10:
10. Don't post the CCS example code or drivers, or ask for such code and drivers.
http://www.ccsinfo.com/forum/viewtopic.php?t=26245
- Forum Moderator
++++++++++++++++++
st7565.h
Code: |
#ifndef _ST7565_H_
#define _ST7565_H_
/** Command: turn the display on */
#define GLCD_CMD_DISPLAY_ON 0b10101111
/** Command: turn the display off */
#define GLCD_CMD_DISPLAY_OFF 0b10101110
/** Command: set all points on the screen to normal. */
#define GLCD_CMD_ALL_NORMAL 0b10100100
/** Command: set all points on the screen to "on", without affecting
the internal screen buffer. */
#define GLCD_CMD_ALL_ON 0b10100101
/** Command: disable inverse (black pixels on a white background) */
#define GLCD_CMD_DISPLAY_NORMAL 0b10100110
/** Command: inverse the screen (white pixels on a black background) */
#define GLCD_CMD_DISPLAY_REVERSE 0b10100111
/** Command: set LCD bias to 1/9th */
#define GLCD_CMD_BIAS_9 0b10100010
/** Command: set LCD bias to 1/7th */
#define GLCD_CMD_BIAS_7 0b10100011
/** Command: set ADC output direction to normal. */
#define GLCD_CMD_HORIZONTAL_NORMAL 0b10100000
/** Command: set ADC output direction reverse (horizontally flipped).
Note that you should use the glcd_flip_screen function so that
the width is correctly accounted for. */
#define GLCD_CMD_HORIZONTAL_REVERSE 0b10100001
/** Command: set common output scan direction to normal. */
#define GLCD_CMD_VERTICAL_NORMAL 0b11000000
/** Command: set common output scan direction to reversed (vertically flipped). */
#define GLCD_CMD_VERTICAL_REVERSE 0b11001000
/** Command: select the internal power supply operating mode. */
#define GLCD_CMD_POWER_CONTROL 0b00101000
/** Command: set internal R1/R2 resistor bias (OR with 0..7) */
#define GLCD_CMD_RESISTOR 0b00100000
/** Command: enter volume mode, send this then send another command
byte with the contrast (0..63). The second command
must be sent for the GLCD to exit volume mode. */
#define GLCD_CMD_VOLUME_MODE 0b10000001
#define GLCD_CMD_DISPLAY_START 0b01000000
/** Command: set the least significant 4 bits of the column address. */
#define GLCD_CMD_COLUMN_LOWER 0b00000000
/** Command: set the most significant 4 bits of the column address. */
#define GLCD_CMD_COLUMN_UPPER 0b00010000
/** Command: Set the current page (0..7). */
#define GLCD_CMD_SET_PAGE 0b10110000
/** Command: software reset (note: should be combined with toggling GLCD_RS) */
#define GLCD_CMD_RESET 0b11100010
/** Command: no operation (note: the datasheet suggests sending this periodically
to keep the data connection alive) */
#define GLCD_CMD_NOP 0b11100011
/**
* Initialise the screen. This should be called first.
*/
void glcd_init();
/**
* Send a command byte to the screen. See GLCD_CMD_ constants for
* a list of commands.
*/
void glcd_command(char);
/**
* Send a data byte to the screen.
*/
void glcd_data(char);
/**
* Update the screen with the contents of the RAM buffer.
*/
void glcd_refresh();
/**
* Clear the screen, without affecting the buffer in RAM.
*
* Useful at startup as the memory inside the screen may
* contain "random" data.
*/
void glcd_blank();
/**
* Set a single pixel
*
* @param x The x position, from 1 - SCREEN_WIDTH
* @param y The y position, from 1 - SCREEN_HEIGHT
* @param colour 0 = OFF, any other value = ON
*/
void glcd_pixel(unsigned char x, unsigned char y, unsigned char colour);
/**
* Flip the screen in the alternate direction vertically.
*
* Can be used if the screen is mounted in an enclosure upside
* down.
*/
void glcd_flip_screen(unsigned char flip);
/**
* Inverse the screen, swapping "on" and "off" pixels.
*
* This does not affect the RAM buffer or the screen memory, the controller
* is capable of reversing pixels with a single command.
*/
void glcd_inverse_screen(unsigned char inverse);
/**
* Fill the local RAM buffer with a test pattern and send it to the screen.
*
* Useful for ensuring that the screen is receiving data correctly or for
* adjusting contrast.
*/
void glcd_test_card();
/**
* Set the contrast of the screen. This involves two steps, setting the
* internal resistor ratio (R1:R2) and then the contrast.
*
* Tip: Find a resistor ratio that works well with the screen and stick to it
* throughout. Then adjust the contrast dynamically between 0 and 63.
*
* @param resistor_ratio Ratio of the internal resistors, from 0-7
* @param contrast Contrast, from 0-63
*/
void glcd_contrast(char resistor_ratio, char contrast);
/** Global variable that tracks whether the screen is the "normal" way up. */
unsigned char glcd_flipped = 0;
#endif // _ST7565_H_
|
st7565-config.h
Code: |
// Setup for ST7565R in SPI mode
/** The chip select pin */
#define GLCD_CS1 PIN_A5
/** The reset pin (this is required and should not be tied high) */
#define GLCD_RESET PIN_A2
/** The A0 pin, which selects command or data mode */
#define GLCD_A0 PIN_A0
/** The clock pin */
#define GLCD_SCL PIN_C3
/** The data pin */
#define GLCD_SDA PIN_C5
/** Screen width in pixels (tested with 128) */
#define SCREEN_WIDTH 128
/** Screen height in pixels (tested with 64) */
#define SCREEN_HEIGHT 64
/** Define this if your screen is incorrectly shifted by 4 pixels */
#define ST7565_REVERSE
/** By default we only write pages that have changed. Undefine this
if you want less/faster code at the expense of more SPI operations. */
//#undef ST7565_DIRTY_PAGES 1
|
st7565.c
Code: |
unsigned char glcd_buffer[SCREEN_WIDTH * SCREEN_HEIGHT / 8];
#ifdef ST7565_DIRTY_PAGES
unsigned char glcd_dirty_pages;
#endif
void glcd_pixel(unsigned char x, unsigned char y, unsigned char colour) {
if (x > SCREEN_WIDTH || y > SCREEN_HEIGHT) return;
// Real screen coordinates are 0-63, not 1-64.
x -= 1;
y -= 1;
unsigned short array_pos = x + ((y / 8) * 128);
#ifdef ST7565_DIRTY_PAGES
#warning ** ST7565_DIRTY_PAGES enabled, only changed pages will be written to the GLCD **
glcd_dirty_pages |= 1 << (array_pos / 128);
#endif
if (colour) {
glcd_buffer[array_pos] |= 1 << (y % 8);
} else {
glcd_buffer[array_pos] &= 0xFF ^ 1 << (y % 8);
}
}
void glcd_blank() {
int n,y,x;
// Reset the internal buffer
for (n = 1; n <= (SCREEN_WIDTH * SCREEN_HEIGHT / 8) - 1; ++n) {
glcd_buffer[n] = 0;
}
// Clear the actual screen
for (y = 0; y < 8; y++) {
glcd_command(GLCD_CMD_SET_PAGE | y);
// Reset column to 0 (the left side)
glcd_command(GLCD_CMD_COLUMN_LOWER);
glcd_command(GLCD_CMD_COLUMN_UPPER);
// We iterate to 132 as the internal buffer is 65*132, not
// 64*124.
for (x = 0; x < 132; x++) {
glcd_data(0x00);
}
}
}
void glcd_refresh() {
int y, x;
for (y = 0; y < 8; y++) {
#ifdef ST7565_DIRTY_PAGES
// Only copy this page if it is marked as "dirty"
if (!(glcd_dirty_pages & (1 << y))) continue;
#endif
glcd_command(GLCD_CMD_SET_PAGE | y);
// Reset column to the left side. The internal memory of the
// screen is 132*64, we need to account for this if the display
// is flipped.
//
// Some screens seem to map the internal memory to the screen
// pixels differently, the ST7565_REVERSE define allows this to
// be controlled if necessary.
#ifdef ST7565_REVERSE
if (!glcd_flipped) {
#else
if (glcd_flipped) {
#endif
glcd_command(GLCD_CMD_COLUMN_LOWER | 4);
} else {
glcd_command(GLCD_CMD_COLUMN_LOWER);
}
glcd_command(GLCD_CMD_COLUMN_UPPER);
for (x = 0; x < 128; x++) {
glcd_data(glcd_buffer[y * 128 + x]);
}
}
#ifdef ST7565_DIRTY_PAGES
// All pages have now been updated, reset the indicator.
glcd_dirty_pages = 0;
#endif
}
void glcd_init()
{
output_low(GLCD_SCL); // Initialize SCL
output_low(GLCD_SDA); // Initialize SDA
// Select the chip
output_low(GLCD_CS1);
output_low(GLCD_RESET);
// Datasheet says "wait for power to stabilise" but gives
// no specific time!
delay_ms(50);
output_high(GLCD_RESET);
// Datasheet says max 1ms here
//DelayMs(1);
// Set LCD bias to 1/9th
glcd_command(GLCD_CMD_BIAS_9);
// Horizontal output direction (ADC segment driver selection)
glcd_command(GLCD_CMD_HORIZONTAL_NORMAL);
// Vertical output direction (common output mode selection)
glcd_command(GLCD_CMD_VERTICAL_REVERSE);
// The screen is the "normal" way up
glcd_flipped = 0;
// Set internal resistor. A suitable middle value is used as
// the default.
glcd_command(GLCD_CMD_RESISTOR | 0x3);
// Power control setting (datasheet step 7)
// Note: Skipping straight to 0x7 works with my hardware.
// glcd_command(GLCD_CMD_POWER_CONTROL | 0x4);
// DelayMs(50);
// glcd_command(GLCD_CMD_POWER_CONTROL | 0x6);
// DelayMs(50);
glcd_command(GLCD_CMD_POWER_CONTROL | 0x7);
// DelayMs(10);
// Volume set (brightness control). A middle value is used here
// also.
glcd_command(GLCD_CMD_VOLUME_MODE);
glcd_command(31);
// Reset start position to the top
glcd_command(GLCD_CMD_DISPLAY_START);
// Turn the display on
glcd_command(GLCD_CMD_DISPLAY_ON);
// Unselect the chip
output_high(GLCD_CS1);
}
void glcd_data(unsigned char data) {
int n;
// A0 is high for display data
output_high(GLCD_A0);
// Select the chip
output_low(GLCD_CS1);
for (n = 0; n < 8; n++) {
if (data & 0x80) {
output_high(GLCD_SDA);
} else {
output_low(GLCD_SDA);
}
// Pulse SCL
output_high(GLCD_SCL);
output_low(GLCD_SCL);
data <<= 1;
}
// Unselect the chip
output_high(GLCD_CS1);
}
void glcd_command(char command) {
int n;
// A0 is low for command data
output_low(GLCD_A0);
// Select the chip
output_low(GLCD_CS1);
for (n = 0; n < 8; n++) {
if (command & 0x80) {
output_high(GLCD_SDA);
} else {
output_low(GLCD_SDA);
}
// Pulse SCL
output_high(GLCD_SCL);
output_low(GLCD_SCL);
command <<= 1;
}
// Unselect the chip
output_high(GLCD_CS1);
}
void glcd_flip_screen(unsigned char flip) {
if (flip) {
glcd_command(GLCD_CMD_HORIZONTAL_NORMAL);
glcd_command(GLCD_CMD_VERTICAL_REVERSE);
glcd_flipped = 0;
} else {
glcd_command(GLCD_CMD_HORIZONTAL_REVERSE);
glcd_command(GLCD_CMD_VERTICAL_NORMAL);
glcd_flipped = 1;
}
}
void glcd_inverse_screen(unsigned char inverse) {
if (inverse) {
glcd_command(GLCD_CMD_DISPLAY_REVERSE);
} else {
glcd_command(GLCD_CMD_DISPLAY_NORMAL);
}
}
void glcd_test_card() {
int n;
unsigned char p = 0xF0;
for (n = 1; n <= (SCREEN_WIDTH * SCREEN_HEIGHT / 8); ++n) {
glcd_buffer[n - 1] = p;
if (n % 4 == 0) {
unsigned char q = p;
p = p << 4;
p |= q >> 4;
}
}
glcd_refresh();
}
void glcd_contrast(char resistor_ratio, char contrast) {
if (resistor_ratio > 7 || contrast > 63) return;
glcd_command(GLCD_CMD_RESISTOR | resistor_ratio);
glcd_command(GLCD_CMD_VOLUME_MODE);
glcd_command(contrast);
}
|
18f2685.h
Code deleted by Forum Moderator. |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1355
|
|
Posted: Wed Nov 16, 2016 8:18 am |
|
|
Two things that immediately jump out:
1. Your comments specify there needs to be a delay after asserting the reset line.
2. Your initialization procedure does not match the one specified in the data sheet that you supplied. Page 6 has an init sequence for when you have a separate contrast voltage from VDD (I believe this is what you are doing based on your OP, but slightly guessing here). |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Nov 16, 2016 12:18 pm |
|
|
The document that you gave in this link
http://es.rs-online.com/webdocs/1384/0900766b8138414b.pdf
lists a specific way to initialize the display, but your code doesn't follow it.
Based on the voltages listed in your post, I'd say you were running the
LCD from +3.3v only. The initialization values should be as shown
in this table on page 6 of the PDF file:
Quote: |
INITIALISATION EXAMPLE
Initialisation example for single supply +3.3V (bottom view)
|
Notice that this initialization method does things that you are not doing
in your posted code. For example, it writes to this register:
I notice your voltage levels are on the first five pins are somewhat lower
than the expected values. I think it might be because you never set the
Booster ratio.
This file has sample source code in AVR C. Notice how they set the
booster ratio:
http://www.lcd-module.de/deu/disk/development%20service/DOGM128%20ST7565/INIT_DOG_Grafik_7565.c
Edit your program to use their init values, and do it in the same order
that they do it in. |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1355
|
|
Posted: Wed Nov 16, 2016 1:26 pm |
|
|
Based on their Contrast voltage of over 12 volts, are you sure it is 3.3V only? I leaned the other way, but was curious what tipped you off on the 3.3V only initialization?
EDIT: for reference, this was the data sheet entry that caught my eye:
Quote: |
INITIALISATION EXAMPLE
Using an external power supply for contrast voltage (dual power supply).
Application „LOW VOLTAGE“.
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Nov 16, 2016 2:04 pm |
|
|
I think the main reason is that he lists his Vout pin at 12.47v.
The chart on page 3 of this document shows it at 12.3v.
http://www.lcd-module.de/deu/disk/development%20service/DOGM128%20ST7565/How%20to%20work%20with%20EA%20DOGM128-6.doc
I thought it unlikely that he would supply 12.47v as an external voltage.
I think the 12.47v is probably from the internal Voltage generator.
This was a weighted guess on my part.
He does have one oddball value on pin 31 (CAP3P). The charts says it's
supposed to be 4.8v and he lists 10.96v. That may indicate something
is wrong somewhere. |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1355
|
|
Posted: Wed Nov 16, 2016 2:47 pm |
|
|
Gotcha!
That makes sense. |
|
|
jamalavedra
Joined: 25 Oct 2016 Posts: 62
|
|
Posted: Thu Nov 17, 2016 10:26 am |
|
|
thank you guys. By defining BoostRatio I have finally turned on the GLCD, but it wasn't displaying anything that made sense, just random on pixels that don't follow what i have written in the code
After defining the BoostRatio at the .h file this is what I have modified at the .c file
Code: |
void glcd_init()
{
output_low(GLCD_SCL); // Initialize SCL
output_low(GLCD_SDA); // Initialize SDA
// Select the chip
output_low(GLCD_CS1);
output_low(GLCD_RESET);
// Datasheet says "wait for power to stabilise" but gives
// no specific time!
delay_ms(50);
output_high(GLCD_RESET);
// Datasheet says max 1ms here
//DelayMs(1);
// Horizontal output direction (ADC segment driver selection)
glcd_command(GLCD_CMD_HORIZONTAL_NORMAL);
// Set LCD bias to 1/9th
glcd_command(GLCD_CMD_BIAS_9);
// Power control setting (datasheet step 7)
// Note: Skipping straight to 0x7 works with my hardware.
// glcd_command(GLCD_CMD_POWER_CONTROL | 0x4);
// DelayMs(50);
// glcd_command(GLCD_CMD_POWER_CONTROL | 0x6);
// DelayMs(50);
glcd_command(GLCD_CMD_POWER_CONTROL | 0x7);
glcd_command(GLCD_CMD_RATIO);
glcd_command(0);
// Set internal resistor. A suitable middle value is used as
// the default.
glcd_command(GLCD_CMD_RESISTOR | 0x7);
// Vertical output direction (common output mode selection)
glcd_command(GLCD_CMD_VERTICAL_REVERSE);
// The screen is the "normal" way up
glcd_flipped = 0;
// DelayMs(10);
// Reset start position to the top
glcd_command(GLCD_CMD_DISPLAY_START);
// Volume set (brightness control). A middle value is used here
// also.
glcd_command(GLCD_CMD_VOLUME_MODE);
glcd_command(31);
// Turn the display on
glcd_command(GLCD_CMD_DISPLAY_ON);
// Unselect the chip
output_high(GLCD_CS1);
}
|
the voltage at the pins now has changed at some
21- 10.8v
22- 9.6 V
23- 8.4v
24- 2.4v
25- 1.2 v
26-0v
27- 1.6v
28- 7v
29- 4.45v
30- 1.6v
31-9.59v
32- 10.8v
33-0 v
34- 3.4v
35-3.4v
36- data in
37- serial clk
38- 3.3v
39- 3.3v
40- 3.3v
this is the main program i am using
Code: |
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD); // No analogs
setup_adc(ADC_OFF|ADC_TAD_MUL_0);
// setup_comparator(NC_NC_NC_NC); // Disable comparator
glcd_init();
delay_ms(500);
glcd_contrast(10, 25);
while(1)
{
output_high(PIN_C1);
glcd_pixel(1, 1, 1);
glcd_pixel(2, 1, 1);
glcd_pixel(1, 2, 1);
glcd_pixel(2, 2, 1);
output_low(PIN_C1);
delay_ms(2000);
// Clear a pixel in the RAM buffer
glcd_pixel(64, 64, 0);
delay_ms(1000);
output_high(PIN_C1);
glcd_refresh();
}
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Nov 17, 2016 11:07 am |
|
|
I don't see you clearing the screen. Clear the screen before you
try to write to it. Add the line shown below:
Code: |
glcd_init();
delay_ms(500);
glcd_contrast(10, 25);
glcd_blank(); // *** Add this line
|
|
|
|
jamalavedra
Joined: 25 Oct 2016 Posts: 62
|
|
Posted: Fri Nov 18, 2016 2:59 am |
|
|
hi!, I have tried to add this " glcd_blank(); " command at the main code but then it doesn't even get to enter the while (1) loop. The SDO pin (RC5) of my 18f2685 pic gets a logic 1 all the time.
The display shows all the pixels switched on.
This is the glcd_blank code:
Code: |
void glcd_blank() {
int n,y,x;
// Reset the internal buffer
for (n = 1; n <= (SCREEN_WIDTH * SCREEN_HEIGHT / 8) - 1; ++n) {
glcd_buffer[n] = 0;
}
// Clear the actual screen
for (y = 0; y < 8; y++) {
glcd_command(GLCD_CMD_SET_PAGE | y);
// Reset column to 0 (the left side)
glcd_command(GLCD_CMD_COLUMN_LOWER);
glcd_command(GLCD_CMD_COLUMN_UPPER);
// We iterate to 132 as the internal buffer is 65*132, not
// 64*124.
for (x = 0; x < 132; x++) {
glcd_data(0x00);
}
}
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Nov 18, 2016 10:15 am |
|
|
One problem is that the variable 'n' in the routine below is not big enough
to hold the desired count:
Quote: |
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
void glcd_blank() {
int n,y,x;
// Reset the internal buffer
for (n = 1; n <= (SCREEN_WIDTH * SCREEN_HEIGHT / 8) - 1; ++n) {
glcd_buffer[n] = 0;
}
|
When I compile this code, I get this warning for the for() loop line above:
Quote: |
>>> Warning 203 "PCH_Test.c" Line 16(1,1): Condition always TRUE
|
Do you have warnings enabled ? That should be a clue that something
is wrong.
The code above translates to this:
Quote: | for (n = 1; n <= 1023; ++n)
glcd_buffer[n] = 0; |
Since 'n' can only go from 0 to 255, it will always be less than 1023.
In a for() loop, if the test is true, it stays in the loop. In this case
it will always be true, and it will stay in the loop forever. The program
will be "locked up".
To solve this problem, you need to declare 'n' as an int16, as shown below:
Code: |
int16 n;
int8 x, y;
|
That will fix it and the code will no longer hang in the for() loop.
Let's face it, this driver is not tested. |
|
|
jamalavedra
Joined: 25 Oct 2016 Posts: 62
|
|
Posted: Thu Jan 26, 2017 11:28 am |
|
|
I have figured out the "clear display" and the initialization problem but either the refresh function of the display or the show pixel function are wrong at some point and I am not finding what the error might be.
main code regarding the write of the display
Code: |
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD); // No analogs
setup_adc(ADC_OFF|ADC_TAD_MUL_0);
// setup_comparator(NC_NC_NC_NC); // Disable comparator
glcd_init();
delay_ms(1000);
glcd_blank();
delay_ms(1000);
glcd_contrast(3, 25);
glcd_test_card();
/*while(1)
{
glcd_pixel(1, 1, 1);
glcd_pixel(2, 1, 1);
glcd_pixel(1, 2, 1);
glcd_pixel(2, 2, 1);
delay_ms(2000);
// Clear a pixel in the RAM buffer
glcd_pixel(64, 64, 0);
delay_ms(1000);
output_high(PIN_C2);
glcd_refresh();
|
code for showing a single pixel
Code: |
void glcd_pixel(unsigned char x, unsigned char y, unsigned char colour) {
output_low(GLCD_CS1);
output_high(GLCD_A0);
if (x > SCREEN_WIDTH || y > SCREEN_HEIGHT) return;
// Real screen coordinates are 0-63, not 1-64.
x -= 1;
y -= 1;
unsigned short array_pos = x + ((y / 8) * 128);
#ifdef ST7565_DIRTY_PAGES
#warning ** ST7565_DIRTY_PAGES enabled, only changed pages will be written to the GLCD **
glcd_dirty_pages |= 1 << (array_pos / 128);
#endif
if (colour) {
glcd_buffer[array_pos] |= 1 << (y % 8);
} else {
glcd_buffer[array_pos] &= 0xFF ^ 1 << (y % 8);
}
output_high(GLCD_CS1);
}
|
code for the refresh of the display
Quote: |
void glcd_refresh() {
int y, x;
for (y = 0; y < 8; y++) {
#ifdef ST7565_DIRTY_PAGES
// Only copy this page if it is marked as "dirty"
if (!(glcd_dirty_pages & (1 << y))) continue;
#endif
glcd_command(GLCD_CMD_SET_PAGE | y);
// Reset column to the left side. The internal memory of the
// screen is 132*64, we need to account for this if the display
// is flipped.
//
// Some screens seem to map the internal memory to the screen
// pixels differently, the ST7565_REVERSE define allows this to
// be controlled if necessary.
#ifdef ST7565_REVERSE
if (!glcd_flipped) {
#else
if (glcd_flipped) {
#endif
glcd_command(GLCD_CMD_COLUMN_LOWER | 4);
} else {
glcd_command(GLCD_CMD_COLUMN_LOWER);
}
glcd_command(GLCD_CMD_COLUMN_UPPER);
for (x = 0; x < 128; x++) {
glcd_data(glcd_buffer[y * 128 + x]);
}
}
#ifdef ST7565_DIRTY_PAGES
// All pages have now been updated, reset the indicator.
glcd_dirty_pages = 0;
#endif
}
|
any suggestions? thanks
jaume |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 26, 2017 9:20 pm |
|
|
Quote: | void glcd_pixel(unsigned char x, unsigned char y, unsigned char colour) {
output_low(GLCD_CS1);
output_high(GLCD_A0);
if (x > SCREEN_WIDTH || y > SCREEN_HEIGHT) return;
// Real screen coordinates are 0-63, not 1-64.
x -= 1;
y -= 1;
unsigned short array_pos = x + ((y / 8) * 128); |
unsigned short ? Look up what a 'short' is in the CCS PCH compiler.
It's not what you think. Look in this section of the CCS manual:
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Fri Jan 27, 2017 7:06 am |
|
|
OK, I've never used a GLCD module but, silly basic question.
Is there a command or setup feature that allows you to make it behave like a common character based LCD module?
If so, it'd be a great way to confirm basic operation before getting into the 'math' of pixels,colors and 'other stuff'.
Jay |
|
|
jamalavedra
Joined: 25 Oct 2016 Posts: 62
|
|
Posted: Fri Jan 27, 2017 7:17 am |
|
|
Well, as far as I know , turning on some pixels using the function whose code I attached above is the most basic way of testing the display, although I know it works thanks to the initialization sequence working out well. Today I'll be trying out what pcmprogrammer suggested, despite I'm afraid this isn't the source of the problem
Thanks |
|
|
jamalavedra
Joined: 25 Oct 2016 Posts: 62
|
|
Posted: Fri Jan 27, 2017 9:08 am |
|
|
After changing the type specifier "short" to int it doesn't seem to work either, i believe the error must be at the "refresh code" despite even after using some debuggers the code runs smoothly working just fine in the while(1) loop.
Any ideas?
thanks |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|