rearranged order of hardware initialization
This commit is contained in:
parent
af815a234f
commit
dbfa058d22
3 changed files with 15 additions and 22 deletions
|
@ -2,21 +2,15 @@
|
|||
#include <Wire.h>
|
||||
#include "tft_hal_esp32.h"
|
||||
|
||||
uint8_t SDA_GPIO = 19;
|
||||
uint8_t SCL_GPIO = 22;
|
||||
|
||||
void init_hardware_general_HAL(void) {
|
||||
// Make sure ESP32 is running at full speed
|
||||
setCpuFrequencyMhz(240);
|
||||
|
||||
// For I2C to work correctly, the tft has to be powered.
|
||||
// Otherwise the IMU cannot be initialized.
|
||||
// The tft touch controller, being on the same I2C bus, seems to disturb if not powered.
|
||||
// this is power for the TFT IC
|
||||
pinMode(LCD_EN_GPIO, OUTPUT);
|
||||
digitalWrite(LCD_EN_GPIO, LOW);
|
||||
|
||||
// SDA and SCL need to be set explicitly, because for IMU you cannot set it explicitly in the constructor.
|
||||
// Configure i2c pins and set frequency to 400kHz
|
||||
Wire.begin(SDA_GPIO, SCL_GPIO, 400000);
|
||||
digitalWrite(LCD_EN_GPIO, HIGH);
|
||||
// this is power for backlight LEDs
|
||||
pinMode(LCD_BL_GPIO, OUTPUT);
|
||||
digitalWrite(LCD_BL_GPIO, HIGH);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
#include "tft_hal_esp32.h"
|
||||
#include "sleep_hal_esp32.h"
|
||||
|
||||
uint8_t SDA_GPIO = 19;
|
||||
uint8_t SCL_GPIO = 22;
|
||||
|
||||
uint8_t LCD_BL_GPIO = 4;
|
||||
uint8_t LCD_EN_GPIO = 10;
|
||||
|
||||
|
@ -12,13 +15,6 @@ TS_Point touchPoint;
|
|||
byte backlightBrightness = 255;
|
||||
|
||||
void init_tft(void) {
|
||||
// this is power for the TFT IC
|
||||
pinMode(LCD_EN_GPIO, OUTPUT);
|
||||
digitalWrite(LCD_EN_GPIO, HIGH);
|
||||
// this is power for backlight LEDs
|
||||
pinMode(LCD_BL_GPIO, OUTPUT);
|
||||
digitalWrite(LCD_BL_GPIO, HIGH);
|
||||
|
||||
// Configure the backlight PWM
|
||||
// Manual setup because ledcSetup() briefly turns on the backlight
|
||||
ledc_channel_config_t ledc_channel_left;
|
||||
|
@ -72,6 +68,9 @@ void init_tft(void) {
|
|||
tft.fillScreen(TFT_BLACK);
|
||||
tft.setSwapBytes(true);
|
||||
|
||||
// SDA and SCL need to be set explicitly, because for IMU you cannot set it explicitly in the constructor.
|
||||
// Configure i2c pins and set frequency to 400kHz
|
||||
Wire.begin(SDA_GPIO, SCL_GPIO, 400000);
|
||||
// Setup touchscreen
|
||||
touch.begin(128); // Initialize touchscreen and set sensitivity threshold
|
||||
}
|
||||
|
|
|
@ -47,16 +47,14 @@ int main(int argc, char *argv[]) {
|
|||
Serial.begin(115200);
|
||||
// do some general hardware setup, like powering the TFT, I2C, ...
|
||||
init_hardware_general();
|
||||
// get wakeup reason
|
||||
init_sleep();
|
||||
// Restore settings from internal flash memory
|
||||
init_preferences();
|
||||
// blinking led
|
||||
init_userled();
|
||||
// Power Pin definition
|
||||
init_battery();
|
||||
// get wakeup reason
|
||||
init_sleep();
|
||||
// setup the Inertial Measurement Unit (IMU) for motion detection
|
||||
init_IMU();
|
||||
|
||||
// button Pin definition for hardware keys
|
||||
init_keys();
|
||||
|
@ -90,6 +88,8 @@ int main(int argc, char *argv[]) {
|
|||
// init GUI - will initialize tft, touch and lvgl
|
||||
init_gui();
|
||||
gui_loop(); // Run the LVGL UI once before the loop takes over
|
||||
// setup the Inertial Measurement Unit (IMU) for motion detection. Has to be after init_gui(), otherwise I2C will not work
|
||||
init_IMU();
|
||||
|
||||
// register the scenes and their key_commands_*
|
||||
register_scene_defaultKeys();
|
||||
|
|
Loading…
Reference in a new issue