split the two invert functions
This commit is contained in:
@@ -46,7 +46,7 @@ void app_main()
|
||||
LCD_setStr(buf, 4, LCD_HEIGHT - 10, 0);
|
||||
LCD_updateDisplay();
|
||||
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
vTaskDelay(900 / portTICK_PERIOD_MS);
|
||||
}
|
||||
printf("Restarting now.\n");
|
||||
fflush(stdout);
|
||||
|
||||
+19
-19
@@ -312,7 +312,6 @@ static void LCD_SendByte(bool data_or_command, uint8_t data)
|
||||
assert(ret == ESP_OK); //Should have had no issues.
|
||||
}
|
||||
|
||||
|
||||
// This function sets a pixel on displayMap to your preferred
|
||||
// color. 1=Black, 0= white.
|
||||
void LCD_setPixel(int x, int y, bool bw)
|
||||
@@ -529,8 +528,11 @@ void LCD_clearDisplay(bool bw)
|
||||
// specific x,y coordinate.
|
||||
static void gotoXY(int x, int y)
|
||||
{
|
||||
LCD_SendByte(LCD_COMMAND, 0x80 | x); // Column.
|
||||
LCD_SendByte(LCD_COMMAND, 0x40 | y); // Row. ?
|
||||
const uint8_t cmd[2] = {
|
||||
0x80 | x,
|
||||
0x40 | y,
|
||||
};
|
||||
LCD_SendBytes(LCD_COMMAND, cmd, 2);
|
||||
}
|
||||
|
||||
// This will actually draw on the display, whatever is currently
|
||||
@@ -548,28 +550,26 @@ void LCD_updateDisplay()
|
||||
void LCD_setContrast(uint8_t contrast)
|
||||
{
|
||||
spi_device_acquire_bus(hSPI, portMAX_DELAY);
|
||||
LCD_SendByte(LCD_COMMAND, 0x21); //Tell LCD that extended commands follow
|
||||
LCD_SendByte(LCD_COMMAND, 0x80 | contrast); //Set LCD Vop (Contrast): Try 0xB1(good @ 3.3V) or 0xBF if your display is too dark
|
||||
LCD_SendByte(LCD_COMMAND, 0x20); //Set display mode
|
||||
const uint8_t cmd[3] = {
|
||||
0x21, //Tell LCD that extended commands follow
|
||||
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);
|
||||
}
|
||||
|
||||
/* There are two ways to do this. Either through direct commands
|
||||
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()
|
||||
void LCD_invertDisplay(bool invert)
|
||||
{
|
||||
/* Direct LCD Command option
|
||||
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 */
|
||||
LCD_SendByte(LCD_COMMAND, 0x0C | invert);
|
||||
}
|
||||
|
||||
void LCD_invertDisplayData()
|
||||
{
|
||||
/* Indirect, swap bits in displayMap option: */
|
||||
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
|
||||
@@ -599,7 +599,7 @@ void LCD_setup(void)
|
||||
.max_transfer_sz=LCD_WIDTH * LCD_HEIGHT, // ??? this doesnt seem to do anything in the driver
|
||||
};
|
||||
spi_device_interface_config_t devcfg = {
|
||||
.clock_speed_hz=2 * 1000 * 1000, // Hz
|
||||
.clock_speed_hz=4 * 1000 * 1000, // Hz
|
||||
// enable signal lead/lag
|
||||
.cs_ena_pretrans = 0,
|
||||
.cs_ena_posttrans = 0,
|
||||
@@ -624,7 +624,7 @@ void LCD_setup(void)
|
||||
|
||||
const uint8_t magic[6] = {
|
||||
0x21, // Tell LCD extended commands follow
|
||||
0xB0, // Set LCD Vop (Contrast)
|
||||
0x80 + 40, // Set LCD Vop (Contrast)
|
||||
0x04, // Set Temp coefficent
|
||||
0x14, // LCD bias mode 1:48 (try 0x13)
|
||||
//We must send 0x20 before modifying the display control mode
|
||||
|
||||
+5
-5
@@ -59,11 +59,11 @@ void LCD_updateDisplay();
|
||||
// 40-60 is usually a pretty good range.
|
||||
void LCD_setContrast(uint8_t contrast);
|
||||
|
||||
/* There are two ways to do this. Either through direct commands
|
||||
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();
|
||||
/* Invert colors */
|
||||
void LCD_invertDisplay(bool in_data);
|
||||
|
||||
/* Invert colors (hard change in data; does NOT send to display immediately) */
|
||||
void LCD_invertDisplayData();
|
||||
|
||||
//This sends the magical commands to the PCD8544
|
||||
void LCD_setup(void);
|
||||
|
||||
Reference in New Issue
Block a user