Skip to content

Commit

Permalink
add pay inteface
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed May 17, 2019
1 parent 88d7f47 commit 191ee42
Show file tree
Hide file tree
Showing 8 changed files with 1,191 additions and 65 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,4 +1,5 @@
.vscode
.DS_Store
build
make
make
bin
90 changes: 45 additions & 45 deletions board_def.h
@@ -1,45 +1,45 @@

#ifndef __BOARD_DEF_H
#define __BOARD_DEF_H

// #define UBOX_GPS_MODULE //Turning on will open the M8/M6 GPS module
// #define ACSIP_S7XG_MODULE //Turning on will open the S7XG GPS/LORA module
// #define ENABLE_BLE //Turning on will open the BLE module

#define TFT_MISO 4
#define TFT_MOSI 19
#define TFT_SCLK 18
#define TFT_CS 5
#define TFT_DC 27
#define TFT_RST -1
#define TFT_BL 12

#define SD_CS 13
#define SD_MISO 2
#define SD_MOSI 15
#define SD_SCLK 14

#define I2C_SDA 23
#define I2C_SCL 32

#define SEN_SDA 21
#define SEN_SCL 22

#define UART_TX 33
#define UART_RX 34

#if defined(UBOX_GPS_MODULE)
#define UART_BANUD_RATE 9600
#else
#define UART_BANUD_RATE 115200
#endif

#define USER_BUTTON 36

#define TP_INT 38
#define RTC_INT 37
#define AXP202_INT 35
#define BMA423_INT1 39
#define BMA423_INT2 0

#endif

#ifndef __BOARD_DEF_H
#define __BOARD_DEF_H

//#define UBOX_GPS_MODULE //Turning on will open the M8/M6 GPS module
#define ACSIP_S7XG_MODULE //Turning on will open the S7XG GPS/LORA module
#define ENABLE_BLE //Turning on will open the BLE module

#define TFT_MISO -1
#define TFT_MOSI 19
#define TFT_SCLK 18
#define TFT_CS 5
#define TFT_DC 27
#define TFT_RST -1
#define TFT_BL 12

#define SD_CS 13
#define SD_MISO 2
#define SD_MOSI 15
#define SD_SCLK 14

#define I2C_SDA 23
#define I2C_SCL 32

#define SEN_SDA 21
#define SEN_SCL 22

#define UART_TX 33
#define UART_RX 34

#if defined(UBOX_GPS_MODULE)
#define UART_BANUD_RATE 9600
#else
#define UART_BANUD_RATE 115200
#endif

#define USER_BUTTON 36

#define TP_INT 38
#define RTC_INT 37
#define AXP202_INT 35
#define BMA423_INT1 39
#define BMA423_INT2 0

#endif
316 changes: 316 additions & 0 deletions img_alipay.c

Large diffs are not rendered by default.

541 changes: 541 additions & 0 deletions img_qr.c

Large diffs are not rendered by default.

221 changes: 221 additions & 0 deletions img_wechatpay.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libraries/S7xG_Library
Submodule S7xG_Library updated 1 files
+3 −0 README.MD
32 changes: 23 additions & 9 deletions lv_filesys.cpp
Expand Up @@ -25,16 +25,30 @@ extern xQueueHandle g_event_queue_handle;

SPIClass SDSPI(HSPI);


bool sd_detect()
{
if (digitalRead(4)) {
Serial.println("SD no detected");
return false;
} else {
Serial.println("SD detected");
}
return true;
}

bool sd_init()
{
pinMode(4, INPUT_PULLUP);
if (!sd_detect()) {
return false;
}
SDSPI.begin(SD_SCLK, SD_MISO, SD_MOSI, SD_CS);
if (!f_dev.begin(SD_CS, SDSPI)) {
Serial.println("\nSD Card Mount Failed");
return false;
}

uint8_t cardType = f_dev.cardType();

if (cardType == CARD_NONE) {
Serial.println("No SD_MMC card attached");
return false;
Expand All @@ -58,6 +72,9 @@ bool sd_init()

static void listDir(fs::FS &fs, const char *dirname, uint8_t levels)
{
if (!sd_detect()) {
return ;
}
uint8_t cnt = 0;
File root = fs.open(dirname);
if (!root) {
Expand All @@ -70,19 +87,16 @@ static void listDir(fs::FS &fs, const char *dirname, uint8_t levels)
lv_file_list_add(NULL, 0);
return;
}

File file = root.openNextFile();
while (file) {
if (cnt > 20) {
return;
}
++cnt;
if (file.isDirectory()) {
lv_file_list_add(file.name(), 1);
if (levels) {
listDir(fs, file.name(), levels - 1);
}
} else {
lv_file_list_add(file.name(), 0);
if (++cnt > 50) {
return;
}
}
file = root.openNextFile();
}
Expand Down
51 changes: 42 additions & 9 deletions lv_swatch.c
Expand Up @@ -168,6 +168,9 @@ LV_IMG_DECLARE(img_batt4);
LV_IMG_DECLARE(img_ttgo);
LV_IMG_DECLARE(img_lora);
LV_IMG_DECLARE(img_bluetooth);
LV_IMG_DECLARE(img_alipay);
LV_IMG_DECLARE(img_wechatpay);
LV_IMG_DECLARE(img_qr);

typedef lv_res_t (*lv_menu_action_t) (lv_obj_t *obj);
typedef void (*lv_menu_destory_t) (void);
Expand Down Expand Up @@ -245,17 +248,19 @@ static lv_res_t lv_motion_setting(lv_obj_t *par);
static lv_res_t lv_power_setting(lv_obj_t *par);
static lv_res_t lv_lora_setting(lv_obj_t *par);
static lv_res_t lv_ble_setting(lv_obj_t *par);
static lv_res_t lv_pay(lv_obj_t *par);


static void lv_gps_setting_destroy();
static void lv_wifi_setting_destroy();
static void lv_file_setting_destroy();
static void lv_motion_setting_destroy();
static void lv_connect_wifi(const char *password);
static void lv_power_setting_destroy(void);
static void lv_lora_setting_destroy(void);
static void lv_setting_destroy(void);
static void lv_lora_setting_destroy(void);
static void lv_setting_destroy(void);
static void lv_ble_setting_destroy();

static void lv_pay_destroy();

static lv_res_t lora_Sender(lv_obj_t *obj);
static lv_res_t lora_Receiver(lv_obj_t *obj);
Expand Down Expand Up @@ -313,9 +318,35 @@ static lv_menu_struct_t menu_data[] = {
{.name = "Setting", .callback = lv_setting, .destroy = lv_setting_destroy, .src_img = &img_setting},
{.name = "SD Card", .callback = lv_file_setting, .destroy = lv_file_setting_destroy, .src_img = &img_folder},
{.name = "Sensor", .callback = lv_motion_setting, .destroy = lv_motion_setting_destroy, .src_img = &img_directions},

//pay
{.name = "WechatPay", .callback = lv_pay, .destroy = lv_pay_destroy, .src_img = &img_wechatpay},
{.name = "AliPay", .callback = lv_pay, .destroy = lv_pay_destroy, .src_img = &img_alipay},

};

/*********************************************************************
*
* PAY
*
* ******************************************************************/
static lv_res_t lv_pay(lv_obj_t *par)
{
gContainer = lv_obj_create(par, NULL);
lv_obj_set_size(gContainer, g_menu_view_width, g_menu_view_height);
lv_obj_set_style(gContainer, &lv_style_transp_fit);
lv_obj_t *img = lv_img_create(gContainer, NULL);
lv_img_set_src(img, &img_qr);
lv_obj_align(img, NULL, LV_ALIGN_CENTER, 0, 0);

}

static void lv_pay_destroy()
{
lv_obj_del(gContainer);
gContainer = NULL;
gObjecter = NULL;
}

/*********************************************************************
*
Expand Down Expand Up @@ -487,10 +518,12 @@ void lv_ble_mbox_event(const char *event_txt)
static void lv_ble_setting_destroy()
{
connect = false;
#ifdef ESP32
task_event_data_t event_data;
event_data.type = MESS_EVENT_BLE;
event_data.ble.event = LV_BLE_DISCONNECT;
xQueueSend(g_event_queue_handle, &event_data, portMAX_DELAY);
#endif
lv_obj_del(gContainer);
gContainer = NULL;
gObjecter = NULL;
Expand Down Expand Up @@ -1687,17 +1720,17 @@ void create_menu(lv_obj_t *par)

static const lv_point_t vp[] = {
#if ((BLE_EN) && ((!GPS_EN) && (!S7XG_EN)))
{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0},
{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0},
#elif ((BLE_EN) && (GPS_EN))
{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0},
{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0}, {8, 0},
#elif ((BLE_EN) && (S7XG_EN))
{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0},
{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0},
#elif (S7XG_EN)
{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0},
{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0}, {8, 0},
#elif (GPS_EN)
{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0},
{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0},
#else
{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0},
{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0},
#endif
{LV_COORD_MIN, LV_COORD_MIN}
};
Expand Down

0 comments on commit 191ee42

Please sign in to comment.