Skip to content

Commit

Permalink
Fix known issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ShallowGreen123 committed Dec 3, 2024
1 parent 0b58a32 commit c6135be
Show file tree
Hide file tree
Showing 13 changed files with 268 additions and 22 deletions.
11 changes: 11 additions & 0 deletions examples/cc1101_recv/cc1101_recv.ino
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@

#include <RadioLib.h>
#include "utilities.h"
#include "TFT_eSPI.h"

static float CC1101_freq = 868;
SPIClass radioSPI = SPIClass(HSPI);
CC1101 radio = new Module(BOARD_LORA_CS, BOARD_LORA_IO0, -1, BOARD_LORA_IO2, radioSPI);

void setup()
{
// LORA、SD and LCD use the same spi, in order to avoid mutual influence;
// before powering on, all CS signals should be pulled high and in an unselected state;
pinMode(TFT_CS, OUTPUT);
digitalWrite(TFT_CS, HIGH);
pinMode(BOARD_SD_CS, OUTPUT);
digitalWrite(BOARD_SD_CS, HIGH);
pinMode(BOARD_LORA_CS, OUTPUT);
digitalWrite(BOARD_LORA_CS, HIGH);

// Init system
Serial.begin(115200);

pinMode(BOARD_PWR_EN, OUTPUT);
Expand Down
6 changes: 6 additions & 0 deletions examples/cc1101_recv/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
#define BOARD_SPI_MOSI 9
#define BOARD_SPI_MISO 10

// TF card
#define BOARD_SD_CS 13
#define BOARD_SD_SCK BOARD_SPI_SCK
#define BOARD_SD_MOSI BOARD_SPI_MOSI
#define BOARD_SD_MISO BOARD_SPI_MISO

// LORA
#define BOARD_LORA_CS 12
#define BOARD_LORA_SCK BOARD_SPI_SCK
Expand Down
10 changes: 10 additions & 0 deletions examples/cc1101_recv_irq/cc1101_recv_irq.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ void setFlag(void) {

void setup()
{
// LORA、SD and LCD use the same spi, in order to avoid mutual influence;
// before powering on, all CS signals should be pulled high and in an unselected state;
pinMode(TFT_CS, OUTPUT);
digitalWrite(TFT_CS, HIGH);
pinMode(BOARD_SD_CS, OUTPUT);
digitalWrite(BOARD_SD_CS, HIGH);
pinMode(BOARD_LORA_CS, OUTPUT);
digitalWrite(BOARD_LORA_CS, HIGH);

// Init system
Serial.begin(115200);

pinMode(BOARD_PWR_EN, OUTPUT);
Expand Down
6 changes: 6 additions & 0 deletions examples/cc1101_recv_irq/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
#define BOARD_SPI_MOSI 9
#define BOARD_SPI_MISO 10

// TF card
#define BOARD_SD_CS 13
#define BOARD_SD_SCK BOARD_SPI_SCK
#define BOARD_SD_MOSI BOARD_SPI_MOSI
#define BOARD_SD_MISO BOARD_SPI_MISO

// LORA
#define BOARD_LORA_CS 12
#define BOARD_LORA_SCK BOARD_SPI_SCK
Expand Down
11 changes: 11 additions & 0 deletions examples/cc1101_send/cc1101_send.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include <RadioLib.h>
#include "utilities.h"
#include "TFT_eSPI.h"

static float CC1101_freq = 868;

Expand All @@ -11,6 +12,16 @@ CC1101 radio = new Module(BOARD_LORA_CS, BOARD_LORA_IO0, -1, BOARD_LORA_IO2, rad

void setup()
{
// LORA、SD and LCD use the same spi, in order to avoid mutual influence;
// before powering on, all CS signals should be pulled high and in an unselected state;
pinMode(TFT_CS, OUTPUT);
digitalWrite(TFT_CS, HIGH);
pinMode(BOARD_SD_CS, OUTPUT);
digitalWrite(BOARD_SD_CS, HIGH);
pinMode(BOARD_LORA_CS, OUTPUT);
digitalWrite(BOARD_LORA_CS, HIGH);

// Init system
Serial.begin(115200);

pinMode(BOARD_PWR_EN, OUTPUT);
Expand Down
6 changes: 6 additions & 0 deletions examples/cc1101_send/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
#define BOARD_SPI_MOSI 9
#define BOARD_SPI_MISO 10

// TF card
#define BOARD_SD_CS 13
#define BOARD_SD_SCK BOARD_SPI_SCK
#define BOARD_SD_MOSI BOARD_SPI_MOSI
#define BOARD_SD_MISO BOARD_SPI_MISO

// LORA
#define BOARD_LORA_CS 12
#define BOARD_LORA_SCK BOARD_SPI_SCK
Expand Down
13 changes: 10 additions & 3 deletions examples/cc1101_send_irq/cc1101_send_irq.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,21 @@ void setFlag(void)

void setup()
{
// LORA、SD and LCD use the same spi, in order to avoid mutual influence;
// before powering on, all CS signals should be pulled high and in an unselected state;
pinMode(TFT_CS, OUTPUT);
digitalWrite(TFT_CS, HIGH);
pinMode(BOARD_SD_CS, OUTPUT);
digitalWrite(BOARD_SD_CS, HIGH);
pinMode(BOARD_LORA_CS, OUTPUT);
digitalWrite(BOARD_LORA_CS, HIGH);

// Init system
Serial.begin(115200);

pinMode(BOARD_PWR_EN, OUTPUT);
digitalWrite(BOARD_PWR_EN, HIGH); // Power on CC1101 and WS2812

pinMode(BOARD_LORA_CS, OUTPUT);
digitalWrite(BOARD_LORA_CS, HIGH);

// Set antenna frequency settings
pinMode(BOARD_LORA_SW1, OUTPUT);
pinMode(BOARD_LORA_SW0, OUTPUT);
Expand Down
6 changes: 6 additions & 0 deletions examples/cc1101_send_irq/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
#define BOARD_SPI_MOSI 9
#define BOARD_SPI_MISO 10

// TF card
#define BOARD_SD_CS 13
#define BOARD_SD_SCK BOARD_SPI_SCK
#define BOARD_SD_MOSI BOARD_SPI_MOSI
#define BOARD_SD_MISO BOARD_SPI_MISO

// LORA
#define BOARD_LORA_CS 12
#define BOARD_LORA_SCK BOARD_SPI_SCK
Expand Down
10 changes: 10 additions & 0 deletions examples/factory_test/factory_test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,16 @@ void setup(void)
bool nfc_ret = false;
bool lora_ret = false;

// LORA、SD and LCD use the same spi, in order to avoid mutual influence;
// before powering on, all CS signals should be pulled high and in an unselected state;
pinMode(TFT_CS, OUTPUT);
digitalWrite(TFT_CS, HIGH);
pinMode(BOARD_SD_CS, OUTPUT);
digitalWrite(BOARD_SD_CS, HIGH);
pinMode(BOARD_LORA_CS, OUTPUT);
digitalWrite(BOARD_LORA_CS, HIGH);

// Init system
pinMode(TFT_BL, OUTPUT);
digitalWrite(TFT_BL, LOW);

Expand Down
105 changes: 86 additions & 19 deletions examples/factory_test/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#define UI_THEME_DARK 0
#define UI_THEME_LIGHT 1

uint8_t display_rotation = 3;
uint8_t setting_theme = UI_THEME_DARK;
uint8_t display_rotation = 3;
uint8_t setting_theme = UI_THEME_LIGHT;
uint32_t EMBED_COLOR_BG = 0x161823; // UI 的背景色
uint32_t EMBED_COLOR_FOCUS_ON = 0x91B821; // 组件选中时的颜色
uint32_t EMBED_COLOR_TEXT = 0xffffff; // 文本的颜色
Expand Down Expand Up @@ -1044,13 +1044,78 @@ scr_lifecycle_t screen3 = {
};
#endif
//************************************[ screen 4 ]****************************************** setting
#if 1
/*** UI interfavce ***/
bool __attribute__((weak)) ui_scr4_get_lora_st(void) { return false; }
bool __attribute__((weak)) ui_scr4_get_pmu_st(void) { return false; }
bool __attribute__((weak)) ui_scr4_get_nfc_st(void) { return false; }
bool __attribute__((weak)) ui_scr4_get_sd_st(void) { return false; }
// end
// --------------------- screen 4.1 --------------------- About System
#if 1
static lv_obj_t *scr4_1_cont;

static void entry4_1_anim(lv_obj_t *obj) { entry1_anim(obj); }
static void exit4_1_anim(int user_data, lv_obj_t *obj) { exit1_anim(user_data, obj); }

static void scr4_1_btn_event_cb(lv_event_t * e)
{
if(e->code == LV_EVENT_CLICKED){
exit4_1_anim(SCREEN4_ID, scr4_1_cont);
}
}

static void create4_1(lv_obj_t *parent)
{
scr4_1_cont = lv_obj_create(parent);
lv_obj_set_size(scr4_1_cont, lv_pct(100), lv_pct(100));
lv_obj_set_style_bg_color(scr4_1_cont, lv_color_hex(EMBED_COLOR_BG), LV_PART_MAIN);
lv_obj_set_scrollbar_mode(scr4_1_cont, LV_SCROLLBAR_MODE_OFF);
lv_obj_set_style_border_width(scr4_1_cont, 0, LV_PART_MAIN);
lv_obj_set_style_pad_all(scr4_1_cont, 0, LV_PART_MAIN);

lv_obj_t *label = lv_label_create(scr4_1_cont);
lv_obj_set_style_text_color(label, lv_color_hex(EMBED_COLOR_TEXT), LV_PART_MAIN);
lv_obj_set_style_text_font(label, &Font_Mono_Bold_14, LV_PART_MAIN);
lv_label_set_text(label, "About System");
lv_obj_align(label, LV_ALIGN_TOP_MID, 0, 10);

lv_obj_t *info = lv_label_create(scr4_1_cont);
lv_obj_set_width(info, DISPALY_WIDTH * 0.9);
lv_obj_set_style_text_color(info, lv_color_hex(EMBED_COLOR_TEXT), LV_PART_MAIN);
lv_obj_set_style_text_font(info, &Font_Mono_Bold_14, LV_PART_MAIN);
lv_label_set_long_mode(info, LV_LABEL_LONG_WRAP);
lv_label_set_text_fmt(info, "Version: %s \n"
"----------------------------------- \n"
"CC1101 Init: %s\n"
"NFC Init: %s\n"
"TF Card Init: %s\n"
,
T_EMBED_CC1101_SF_VER,
(ui_scr4_get_lora_st() ? "PASS" : "FAIL"),
(ui_scr4_get_nfc_st() ? "PASS" : "FAIL"),
(ui_scr4_get_sd_st() ? "PASS" : "FAIL")
);

lv_obj_align_to(info, label, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);

// back bottom
scr_back_btn_create(scr4_1_cont, scr4_1_btn_event_cb);
}
static void entry4_1(void) {
entry4_1_anim(scr4_1_cont);
}
static void exit4_1(void) {}
static void destroy4_1(void) {}

static scr_lifecycle_t screen4_1 = {
.create = create4_1,
.entry = entry4_1,
.exit = exit4_1,
.destroy = destroy4_1,
};
#endif
// --------------------- screen 4 -----------------------
#if 1

lv_obj_t *scr4_cont;
lv_obj_t *setting_list;
Expand Down Expand Up @@ -1148,14 +1213,15 @@ void setting_scr_event(lv_event_t *e)
lv_anim_start(&a);
break;
case 4: {// "About System"
char buf[128];
lv_snprintf(buf, 128, "LORA init --- %s\n"
"NFC init ---- %s\n"
"TF card ----- %s",
(ui_scr4_get_lora_st() ? "PASS" : "FAIL"),
(ui_scr4_get_nfc_st() ? "PASS" : "FAIL"),
(ui_scr4_get_sd_st() ? "PASS" : "FAIL"));
prompt_info(buf, 1000);
// char buf[128];
// lv_snprintf(buf, 128, "LORA init --- %s\n"
// "NFC init ---- %s\n"
// "TF card ----- %s",
// (ui_scr4_get_lora_st() ? "PASS" : "FAIL"),
// (ui_scr4_get_nfc_st() ? "PASS" : "FAIL"),
// (ui_scr4_get_sd_st() ? "PASS" : "FAIL"));
// prompt_info(buf, 1000);
scr_mgr_switch(SCREEN4_1_ID, false);
} break;
default:
break;
Expand Down Expand Up @@ -1339,17 +1405,17 @@ void batt_timer_event(lv_timer_t *t)
lv_snprintf(buf, 16, "%.2fV", (bq27220.getVolt(VOLT_CHARGING) /1000.0));
battery_set_line(batt_line[2], "VOLT Charge:", buf);

lv_snprintf(buf, 16, "%dmA", bq27220.getCurr(CURR_AVERAGE));
battery_set_line(batt_line[3], "CURR Average:", buf);

lv_snprintf(buf, 16, "%dmA", bq27220.getCurr(CURR_INSTANT));
battery_set_line(batt_line[4], "CURR Standby:", buf);

lv_snprintf(buf, 16, "%dmA", bq27220.getCurr(CURR_CHARGING));
battery_set_line(batt_line[5], "CURR Charging:", buf);
battery_set_line(batt_line[3], "CURR Standby:", buf);

lv_snprintf(buf, 16, "%.2f", (float)(bq27220.getTemp() / 10 - 273));
battery_set_line(batt_line[6], "TEMP:", buf);
battery_set_line(batt_line[4], "TEMP:", buf);

lv_snprintf(buf, 16, "%d", bq27220.getRemainCap());
battery_set_line(batt_line[5], "CAP BATT:", buf);

lv_snprintf(buf, 16, "%d", bq27220.getFullChargeCap());
battery_set_line(batt_line[6], "CAP BATT FULL:", buf);
}
}

Expand Down Expand Up @@ -2336,6 +2402,7 @@ void ui_entry(void)
scr_mgr_register(SCREEN2_ID, &screen2); // lora
scr_mgr_register(SCREEN3_ID, &screen3); // nfc
scr_mgr_register(SCREEN4_ID, &screen4); // setting
scr_mgr_register(SCREEN4_1_ID, &screen4_1); // setting - about
scr_mgr_register(SCREEN5_ID, &screen5); // battery
scr_mgr_register(SCREEN6_ID, &screen6); // wifi
scr_mgr_register(SCREEN7_ID, &screen7); // other
Expand Down
4 changes: 4 additions & 0 deletions examples/factory_test/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include "assets/assets.h"
#include "peripheral/peripheral.h"


#define T_EMBED_CC1101_SF_VER "v1.0 24.12.03"

// The default is landscape screen, HEIGHT and WIDTH swap
#define DISPALY_WIDTH TFT_HEIGHT
#define DISPALY_HEIGHT TFT_WIDTH
Expand All @@ -27,6 +30,7 @@ enum{
SCREEN2_ID,
SCREEN3_ID,
SCREEN4_ID,
SCREEN4_1_ID,
SCREEN5_ID,
SCREEN6_ID,
SCREEN7_ID,
Expand Down
13 changes: 13 additions & 0 deletions examples/tf_card_test/tf_card_test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
#include "FS.h"
#include "SD.h"
#include "SPI.h"
#include "utilities.h"

#include "TFT_eSPI.h"

/*
Uncomment and set up if you want to use custom pins for the SPI communication
Expand Down Expand Up @@ -215,6 +218,16 @@ void testFileIO(fs::FS &fs, const char * path){
}

void setup(){
// LORA、SD and LCD use the same spi, in order to avoid mutual influence;
// before powering on, all CS signals should be pulled high and in an unselected state;
pinMode(TFT_CS, OUTPUT);
digitalWrite(TFT_CS, HIGH);
pinMode(BOARD_SD_CS, OUTPUT);
digitalWrite(BOARD_SD_CS, HIGH);
pinMode(BOARD_LORA_CS, OUTPUT);
digitalWrite(BOARD_LORA_CS, HIGH);

// Init system
Serial.begin(115200);
while(!Serial) { delay (10); }

Expand Down
Loading

0 comments on commit c6135be

Please sign in to comment.