Skip to content

Commit

Permalink
Add a peripheral adaptation to optimize the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ShallowGreen123 committed Dec 30, 2024
1 parent 7f3dc9f commit ad9cdb3
Show file tree
Hide file tree
Showing 5 changed files with 230 additions and 82 deletions.
36 changes: 25 additions & 11 deletions examples/factory/factory.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ bool flag_LTR553ALS_init = false;
/*********************************************************************************
* STATIC PROTOTYPES
* *******************************************************************************/
static void helloWorld()
static bool ink_screen_init()
{
// SPI.begin(BOARD_SPI_SCK, -1, BOARD_SPI_MOSI, BOARD_EPD_CS);
display.init(115200, true, 2, false);
Expand All @@ -70,6 +70,7 @@ static void helloWorld()
}
while (display.nextPage());
display.hibernate();
return true;
}

static void flush_timer_cb(lv_timer_t *t)
Expand Down Expand Up @@ -233,6 +234,13 @@ static bool bq25896_init(void)
return false;
}

static bool GPS_AT_init(void)
{
// GPS AT init
SerialGPS.begin(38400, SERIAL_8N1, BOARD_GPS_RXD, BOARD_GPS_TXD);
return true;
}

void setup()
{
// LORA、SD、EPD use the same SPI, in order to avoid mutual influence;
Expand Down Expand Up @@ -301,13 +309,20 @@ void setup()

// init peripheral
touch.setPins(BOARD_TOUCH_RST, BOARD_TOUCH_INT);
peri_init_st[E_PERI_TOUCH] = touch.begin(Wire, BOARD_I2C_ADDR_TOUCH, BOARD_TOUCH_SDA, BOARD_TOUCH_SCL);
peri_init_st[E_PERI_KYEPAD] = keypad_init(BOARD_I2C_ADDR_KEYBOARD);
peri_init_st[E_PERI_BQ25896] = bq25896_init();
peri_init_st[E_PERI_BQ27220] = false;
peri_init_st[E_PERI_LORA] = lora_init();
peri_init_st[E_PERI_SD] = SD.begin(BOARD_SD_CS);
peri_init_st[E_PERI_INK_SCREEN] = false;
peri_init_st[E_PERI_INK_SCREEN] = ink_screen_init();
peri_init_st[E_PERI_LORA] = lora_init();
peri_init_st[E_PERI_TOUCH] = touch.begin(Wire, BOARD_I2C_ADDR_TOUCH, BOARD_TOUCH_SDA, BOARD_TOUCH_SCL);
peri_init_st[E_PERI_KYEPAD] = keypad_init(BOARD_I2C_ADDR_KEYBOARD);
peri_init_st[E_PERI_BQ25896] = bq25896_init();
peri_init_st[E_PERI_BQ27220] = false;
peri_init_st[E_PERI_SD] = SD.begin(BOARD_SD_CS);
peri_init_st[E_PERI_GPS] = GPS_AT_init();
peri_init_st[E_PERI_BHI260AP] = BHI260AP_init();
peri_init_st[E_PERI_LTR_553ALS] = LTR553_init();
peri_init_st[E_PERI_A7682E] = false;
peri_init_st[E_PERI_PCM5102A] = false;


// touch.setPins(BOARD_TOUCH_RST, BOARD_TOUCH_INT);
// flag_Touch_init = touch.begin(Wire, BOARD_I2C_ADDR_TOUCH, BOARD_TOUCH_SDA, BOARD_TOUCH_SCL);
// if (!flag_Touch_init) {
Expand All @@ -321,7 +336,7 @@ void setup()
// SPI
// SPI.begin(BOARD_SPI_SCK, BOARD_SPI_MISO, BOARD_SPI_MOSI);

helloWorld();

// delay(1000);

// if(SD.begin(BOARD_SD_CS)) {
Expand All @@ -334,8 +349,7 @@ void setup()
// lora
// flag_lora_init = lora_init();

// GPS AT init
SerialGPS.begin(38400, SERIAL_8N1, BOARD_GPS_RXD, BOARD_GPS_TXD);


lvgl_init();

Expand Down
20 changes: 15 additions & 5 deletions examples/factory/peripheral.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@

enum {
E_PERI_LORA = 0,
E_PERI_TOUCH,
E_PERI_KYEPAD,
E_PERI_BQ25896,
E_PERI_BQ27220,
E_PERI_SD,
E_PERI_GPS,
E_PERI_BHI260AP,
E_PERI_INK_SCREEN,
E_PERI_LTR_553ALS,
E_PERI_TOUCH,
E_PERI_MIC,
E_PERI_SD,
E_PERI_A7683E,
E_PERI_A7682E,
E_PERI_PCM5102A,
E_PERI_INK_SCREEN,
E_PERI_MIC,
E_PERI_NUM_MAX,
};

Expand Down Expand Up @@ -42,4 +42,14 @@ int keypad_get_val(char *c);
void keypad_loop(void);
void keypad_regetser_cb(keypad_cb cb);
void keypad_set_flag(void);

// gyro
bool BHI260AP_init(void);
void BHI260AP_get_val(int val_type, float *x, float *y, float *z);

// LTR553
bool LTR553_init(void);
uint16_t LTR_553ALS_get_channel(int ch); // ch 0~1
uint16_t LTR_553ALS_get_ps(void);

#endif
Loading

0 comments on commit ad9cdb3

Please sign in to comment.