You've already forked Core2forAWS-MicroPython
mirror of
https://github.com/m5stack/Core2forAWS-MicroPython.git
synced 2026-05-20 10:30:31 -07:00
update sdkconfig, add tft thread lock
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
set(SDKCONFIG_DEFAULTS
|
||||
boards/sdkconfig.base
|
||||
boards/sdkconfig.ble
|
||||
boards/EduKit/sdkconfig.board
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# Notes: the offset of the partition table itself is set in
|
||||
# $ESPIDF/components/partition_table/Kconfig.projbuild and the
|
||||
# offset of the factory/ota_0 partition is set in makeimg.py
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
nvs, data, nvs, 0x9000, 0x6000,
|
||||
phy_init, data, phy, 0xf000, 0x1000,
|
||||
factory, app, factory, 0x10000, 0x200000,
|
||||
vfs, data, fat, 0x210000, 0x190000,
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,7 @@
|
||||
#include "math.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp32_hal_spi.h"
|
||||
@@ -16,7 +17,16 @@
|
||||
static float _angleOffset = -90;
|
||||
|
||||
extern spi_device_handle_t spi_handle;
|
||||
QueueHandle_t spi_lock;
|
||||
|
||||
/* ------------------------------low method------------------------------- */
|
||||
static void host_select(tft_host_t* host) {
|
||||
xSemaphoreTake(spi_lock, portMAX_DELAY);
|
||||
}
|
||||
|
||||
static void host_deselect(tft_host_t* host) {
|
||||
xSemaphoreGive(spi_lock);
|
||||
}
|
||||
|
||||
static void selectDC(tft_host_t* host, uint8_t level) {
|
||||
if (host->base.dc < 0) {
|
||||
@@ -80,6 +90,7 @@ static void transferAddrWin(tft_host_t* host, uint16_t x1, uint16_t x2, uint16_t
|
||||
|
||||
static void setRotation(tft_host_t* host, uint8_t rot) {
|
||||
uint8_t madctl = 0;
|
||||
host->select(host);
|
||||
|
||||
if (rot & 0x01) {
|
||||
host->_width = host->base.hight;
|
||||
@@ -107,13 +118,23 @@ static void setRotation(tft_host_t* host, uint8_t rot) {
|
||||
}
|
||||
|
||||
host->writeCmdData(host, TFT_MADCTL, &madctl, 1);
|
||||
host->deselect(host);
|
||||
}
|
||||
|
||||
static void drawPixel(tft_host_t* host, int16_t x, int16_t y, uint32_t color) {
|
||||
if ((x > host->_width) || (y > host->_hight) || (x < 0) || (y < 0)) { return; }
|
||||
host->select(host);
|
||||
host->transferAddrWin(host, x, x + 1, y, y + 1);
|
||||
color = ((color >> 8) & 0xff) | ((color & 0xff) << 8);
|
||||
host->writeCmdData(host, TFT_RAMWR, (uint8_t *)&color, 2);
|
||||
host->deselect(host);
|
||||
}
|
||||
|
||||
static void pushColor(tft_host_t* host, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint32_t color, uint32_t len, uint8_t wait) {
|
||||
if (len == 0) {
|
||||
return ;
|
||||
}
|
||||
|
||||
host->select(host);
|
||||
host->transferAddrWin(host, x1, x2, y1, y2);
|
||||
|
||||
host->writeCmd(host, TFT_RAMWR);
|
||||
@@ -135,7 +156,8 @@ static void pushColor(tft_host_t* host, uint16_t x1, uint16_t y1, uint16_t x2, u
|
||||
|
||||
if (wait) {
|
||||
spiWaitFinish(spi_handle);
|
||||
}
|
||||
host->deselect(host);
|
||||
}
|
||||
}
|
||||
|
||||
static void pushColorBuffer(tft_host_t* host, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t* color, uint32_t len) {
|
||||
@@ -272,13 +294,6 @@ static void fillArcOffsetted(tft_host_t* host, uint16_t cx, uint16_t cy, uint16_
|
||||
}
|
||||
|
||||
/* -------------------------- draw method ----------------------------- */
|
||||
static void drawPixel(tft_host_t* host, int16_t x, int16_t y, uint32_t color) {
|
||||
if ((x > host->_width) || (y > host->_hight) || (x < 0) || (y < 0)) { return; }
|
||||
host->transferAddrWin(host, x, x + 1, y, y + 1);
|
||||
color = ((color >> 8) & 0xff) | ((color & 0xff) << 8);
|
||||
host->writeCmdData(host, TFT_RAMWR, (uint8_t *)&color, 2);
|
||||
}
|
||||
|
||||
static void drawFastVLine(tft_host_t* host, int16_t x, int16_t y, int16_t h, uint32_t color) {
|
||||
if ((x < 0) || (x > host->_width) || (y > host->_hight)) { return ; }
|
||||
if (y < 0) { h += y; y = 0; }
|
||||
@@ -831,4 +846,8 @@ void LcdHostInitDefault(tft_host_t* host) {
|
||||
printf("tft memory malloc failed (%dKB)", TRANS_MAX_SIZE / 1024);
|
||||
return ;
|
||||
}
|
||||
|
||||
spi_lock = xSemaphoreCreateMutex();
|
||||
host->select = host_select;
|
||||
host->deselect = host_deselect;
|
||||
}
|
||||
|
||||
@@ -172,6 +172,9 @@ typedef struct _tft_host_t {
|
||||
uint8_t* trans_cline;
|
||||
text_cursor_t text_cursor;
|
||||
|
||||
void (*select)(tft_host_t* host);
|
||||
void (*deselect)(tft_host_t* host);
|
||||
|
||||
void (*selectDC)(tft_host_t* host, uint8_t level);
|
||||
void (*writeCmd)(tft_host_t* host, uint8_t cmd);
|
||||
void (*writeCmdData)(tft_host_t* host, uint8_t cmd, const uint8_t* data, uint16_t len);
|
||||
|
||||
@@ -36,8 +36,6 @@ for datum in range(9):
|
||||
|
||||
lcd.font(lcd.FONT_DejaVu26)
|
||||
lcd.text(160, 120, "fgG", lcd.WHITE, bgcolor=lcd.WHITE, textdatum=datum)
|
||||
|
||||
lcd.font(lcd.FONT_DejaVu14)
|
||||
lcd.drawCircle(160, 120, 5, lcd.GREEN)
|
||||
lcd.drawPixel(160, 120, lcd.GREEN)
|
||||
|
||||
@@ -62,7 +60,6 @@ lcd.print("print demo\r\n", 0, 0)
|
||||
lcd.setCursor(1, 40)
|
||||
lcd.print("hia" * 20)
|
||||
|
||||
lcd.drawRect(0, 0, 160, 120, lcd.GREEN)
|
||||
|
||||
from machine import Pin
|
||||
from M5Library import I2S
|
||||
@@ -93,5 +90,8 @@ def micro_show(y_offset=120):
|
||||
lcd.line(i * 2 + 44, y_offset + buffer[i], i * 2 + 44 + 2, y_offset + buffer[i + 1], lcd.BLACK)
|
||||
|
||||
lcd.clear(lcd.WHITE)
|
||||
|
||||
while True:
|
||||
micro_show()
|
||||
|
||||
# print(test())
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
// Until we move to IDF 4.2+, we need NimBLE on core 0, and for synchronisation
|
||||
// with the ringbuffer and scheduler MP needs to be on the same core.
|
||||
// See https://github.com/micropython/micropython/issues/5489
|
||||
#define MP_TASK_COREID (0)
|
||||
#define MP_TASK_COREID (1)
|
||||
|
||||
extern TaskHandle_t mp_main_task_handle;
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ void mp_thread_finish(void) {
|
||||
}
|
||||
|
||||
void vPortCleanUpTCB(void *tcb) {
|
||||
if (thread == NULL) {
|
||||
if (thread == NULL || thread_mutex.handle == NULL) {
|
||||
// threading not yet initialised
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
nvs, data, nvs, 0x9000, 0x6000,
|
||||
phy_init, data, phy, 0xf000, 0x1000,
|
||||
factory, app, factory, 0x10000, 0x180000,
|
||||
vfs, data, fat, 0x200000, 0x200000,
|
||||
factory, app, factory, 0x10000, 0x200000,
|
||||
vfs, data, fat, 0x210000, 0x190000,
|
||||
|
||||
|
Reference in New Issue
Block a user