split the two invert functions

gui-framework
Ondřej Hruška 4 years ago
parent 27553868e5
commit b241ee9873
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 2
      main/hello_world_main.c
  2. 38
      main/nokia.c
  3. 10
      main/nokia.h

@ -46,7 +46,7 @@ void app_main()
LCD_setStr(buf, 4, LCD_HEIGHT - 10, 0); LCD_setStr(buf, 4, LCD_HEIGHT - 10, 0);
LCD_updateDisplay(); LCD_updateDisplay();
vTaskDelay(1000 / portTICK_PERIOD_MS); vTaskDelay(900 / portTICK_PERIOD_MS);
} }
printf("Restarting now.\n"); printf("Restarting now.\n");
fflush(stdout); fflush(stdout);

@ -312,7 +312,6 @@ static void LCD_SendByte(bool data_or_command, uint8_t data)
assert(ret == ESP_OK); //Should have had no issues. assert(ret == ESP_OK); //Should have had no issues.
} }
// This function sets a pixel on displayMap to your preferred // This function sets a pixel on displayMap to your preferred
// color. 1=Black, 0= white. // color. 1=Black, 0= white.
void LCD_setPixel(int x, int y, bool bw) void LCD_setPixel(int x, int y, bool bw)
@ -529,8 +528,11 @@ void LCD_clearDisplay(bool bw)
// specific x,y coordinate. // specific x,y coordinate.
static void gotoXY(int x, int y) static void gotoXY(int x, int y)
{ {
LCD_SendByte(LCD_COMMAND, 0x80 | x); // Column. const uint8_t cmd[2] = {
LCD_SendByte(LCD_COMMAND, 0x40 | y); // Row. ? 0x80 | x,
0x40 | y,
};
LCD_SendBytes(LCD_COMMAND, cmd, 2);
} }
// This will actually draw on the display, whatever is currently // This will actually draw on the display, whatever is currently
@ -548,28 +550,26 @@ void LCD_updateDisplay()
void LCD_setContrast(uint8_t contrast) void LCD_setContrast(uint8_t contrast)
{ {
spi_device_acquire_bus(hSPI, portMAX_DELAY); spi_device_acquire_bus(hSPI, portMAX_DELAY);
LCD_SendByte(LCD_COMMAND, 0x21); //Tell LCD that extended commands follow const uint8_t cmd[3] = {
LCD_SendByte(LCD_COMMAND, 0x80 | contrast); //Set LCD Vop (Contrast): Try 0xB1(good @ 3.3V) or 0xBF if your display is too dark 0x21, //Tell LCD that extended commands follow
LCD_SendByte(LCD_COMMAND, 0x20); //Set display mode 0x80 | contrast,//Set LCD Vop (Contrast): Try 0xB1(good @ 3.3V) or 0xBF if your display is too dark
0x20,//Set display mode
};
LCD_SendBytes(LCD_COMMAND, cmd, 3);
spi_device_release_bus(hSPI); spi_device_release_bus(hSPI);
} }
/* There are two ways to do this. Either through direct commands void LCD_invertDisplay(bool invert)
to the display, or by swapping each bit in the displayMap array.
We'll leave both methods here, comment one or the other out if
you please. */
void LCD_invertDisplay()
{ {
/* Direct LCD Command option LCD_SendByte(LCD_COMMAND, 0x0C | invert);
LCDWrite(LCD_COMMAND, 0x20); //Tell LCD that extended commands follow }
LCDWrite(LCD_COMMAND, 0x08 | 0x05); //Set LCD Vop (Contrast): Try 0xB1(good @ 3.3V) or 0xBF if your display is too dark
LCDWrite(LCD_COMMAND, 0x20); //Set display mode */
void LCD_invertDisplayData()
{
/* Indirect, swap bits in displayMap option: */ /* Indirect, swap bits in displayMap option: */
for (int i = 0; i < (LCD_WIDTH * LCD_HEIGHT / 8); i++) { for (int i = 0; i < (LCD_WIDTH * LCD_HEIGHT / 8); i++) {
displayMap[i] = ~displayMap[i] & 0xFF; displayMap[i] ^= 0xFF;
} }
LCD_updateDisplay();
} }
//This function is called (in irq context!) just before a transmission starts. It will //This function is called (in irq context!) just before a transmission starts. It will
@ -599,7 +599,7 @@ void LCD_setup(void)
.max_transfer_sz=LCD_WIDTH * LCD_HEIGHT, // ??? this doesnt seem to do anything in the driver .max_transfer_sz=LCD_WIDTH * LCD_HEIGHT, // ??? this doesnt seem to do anything in the driver
}; };
spi_device_interface_config_t devcfg = { spi_device_interface_config_t devcfg = {
.clock_speed_hz=2 * 1000 * 1000, // Hz .clock_speed_hz=4 * 1000 * 1000, // Hz
// enable signal lead/lag // enable signal lead/lag
.cs_ena_pretrans = 0, .cs_ena_pretrans = 0,
.cs_ena_posttrans = 0, .cs_ena_posttrans = 0,
@ -624,7 +624,7 @@ void LCD_setup(void)
const uint8_t magic[6] = { const uint8_t magic[6] = {
0x21, // Tell LCD extended commands follow 0x21, // Tell LCD extended commands follow
0xB0, // Set LCD Vop (Contrast) 0x80 + 40, // Set LCD Vop (Contrast)
0x04, // Set Temp coefficent 0x04, // Set Temp coefficent
0x14, // LCD bias mode 1:48 (try 0x13) 0x14, // LCD bias mode 1:48 (try 0x13)
//We must send 0x20 before modifying the display control mode //We must send 0x20 before modifying the display control mode

@ -59,11 +59,11 @@ void LCD_updateDisplay();
// 40-60 is usually a pretty good range. // 40-60 is usually a pretty good range.
void LCD_setContrast(uint8_t contrast); void LCD_setContrast(uint8_t contrast);
/* There are two ways to do this. Either through direct commands /* Invert colors */
to the display, or by swapping each bit in the displayMap array. void LCD_invertDisplay(bool in_data);
We'll leave both methods here, comment one or the other out if
you please. */ /* Invert colors (hard change in data; does NOT send to display immediately) */
void LCD_invertDisplay(); void LCD_invertDisplayData();
//This sends the magical commands to the PCD8544 //This sends the magical commands to the PCD8544
void LCD_setup(void); void LCD_setup(void);

Loading…
Cancel
Save