mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-23 15:07:38 +01:00
Merge branch 'jjwbruijn:master' into master
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "zigbee.h"
|
||||
#include "epd_spi.h"
|
||||
#include "eeprom_spi.h"
|
||||
#include "epd_driver/epd_interface.h"
|
||||
|
||||
#define RADIO_FIRST_CHANNEL (11) // 2.4-GHz channels start at 11
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
// hw types
|
||||
#define HW_TYPE SOLUM_M3_BWR_22
|
||||
|
||||
#include "../include/ssd1619.h"
|
||||
|
||||
#define SCREEN_WIDTH 160
|
||||
#define SCREEN_HEIGHT 296
|
||||
#define SCREEN_XOFFSET 8
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
// hw types
|
||||
#define HW_TYPE SOLUM_M3_BWR_29
|
||||
|
||||
#include "../include/ssd1619.h"
|
||||
|
||||
#define SCREEN_WIDTH 168
|
||||
#define SCREEN_HEIGHT 384
|
||||
#define SCREEN_XOFFSET 8
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
// hw type
|
||||
#define HW_TYPE SOLUM_M3_BWR_43
|
||||
#include "../include/uc_variant_043.h"
|
||||
|
||||
#define SCREEN_WIDTH 152
|
||||
#define SCREEN_HEIGHT 522
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
// hw type
|
||||
#define HW_TYPE SOLUM_M3_BWR_60
|
||||
|
||||
#include "../include/uc8159.h"
|
||||
|
||||
#define SCREEN_WIDTH 600
|
||||
#define SCREEN_HEIGHT 448
|
||||
#define SCREEN_XOFFSET 0
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
// hw type
|
||||
#define HW_TYPE SOLUM_M3_BWR_75
|
||||
|
||||
#include "../include/uc8179.h"
|
||||
|
||||
#define SCREEN_WIDTH 800
|
||||
#define SCREEN_HEIGHT 480
|
||||
#define SCREEN_XOFFSET 0
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "../hal/Newton_M3_nRF52811/Newton_M3_nRF52811_22_BWR.h"
|
||||
#include "../hal/Newton_M3_nRF52811/HAL_Newton_M3.h"
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_NEWTON_M3_29_BWR
|
||||
#include "../hal/Newton_M3_nRF52811/Newton_M3_nRF52811_29_BWR.h"
|
||||
#include "../hal/Newton_M3_nRF52811/HAL_Newton_M3.h"
|
||||
@@ -12,7 +13,6 @@
|
||||
#include "../hal/Newton_M3_nRF52811/HAL_Newton_M3.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef BUILD_NEWTON_M3_60_BWR
|
||||
#include "../hal/Newton_M3_nRF52811/Newton_M3_nRF52811_60_BWR.h"
|
||||
#include "../hal/Newton_M3_nRF52811/HAL_Newton_M3.h"
|
||||
@@ -21,5 +21,4 @@
|
||||
#ifdef BUILD_NEWTON_M3_75_BWR
|
||||
#include "../hal/Newton_M3_nRF52811/Newton_M3_nRF52811_75_BWR.h"
|
||||
#include "../hal/Newton_M3_nRF52811/HAL_Newton_M3.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,23 +0,0 @@
|
||||
#ifndef _JSCREEN_H_
|
||||
#define _JSCREEN_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define EPD_LUT_DEFAULT 0
|
||||
#define EPD_LUT_NO_REPEATS 1
|
||||
#define EPD_LUT_FAST_NO_REDS 2
|
||||
#define EPD_LUT_FAST 3
|
||||
|
||||
void epdSetup();
|
||||
void epdEnterSleep();
|
||||
|
||||
|
||||
void draw();
|
||||
void drawNoWait();
|
||||
|
||||
void epdWaitRdy();
|
||||
|
||||
void selectLUT(uint8_t lut);
|
||||
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
#ifndef _JSCREEN_H_
|
||||
#define _JSCREEN_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define EPD_LUT_DEFAULT 0
|
||||
#define EPD_LUT_NO_REPEATS 1
|
||||
#define EPD_LUT_FAST_NO_REDS 2
|
||||
#define EPD_LUT_FAST 3
|
||||
|
||||
|
||||
void epdSetup();
|
||||
void epdEnterSleep();
|
||||
|
||||
|
||||
void draw();
|
||||
void drawNoWait();
|
||||
void epdWaitRdy();
|
||||
|
||||
void selectLUT(uint8_t lut);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,23 +0,0 @@
|
||||
#ifndef _JSCREEN_H_
|
||||
#define _JSCREEN_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define EPD_LUT_DEFAULT 0
|
||||
#define EPD_LUT_NO_REPEATS 1
|
||||
#define EPD_LUT_FAST_NO_REDS 2
|
||||
#define EPD_LUT_FAST 3
|
||||
|
||||
void epdSetup();
|
||||
void epdEnterSleep();
|
||||
|
||||
void draw();
|
||||
void drawNoWait();
|
||||
void drawWithSleep();
|
||||
void epdWaitRdy();
|
||||
|
||||
void selectLUT(uint8_t lut);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -20,18 +20,30 @@ extra_scripts = post:preparefiles.py
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-D BUILD_NEWTON_M3_22_BWR
|
||||
-D EPD_DRIVER=SSD1619
|
||||
-Tnrf52811_bootloader.ld
|
||||
build_src_filter =
|
||||
+<*>-<uc_variant_043.cpp>-<uc8179.cpp>-<uc8159.cpp>+<../hal/Newton_M3_nRF52811/*>
|
||||
+<*>-<epd_driver/*>+<../hal/Newton_M3_nRF52811/*>
|
||||
|
||||
[env:Newton_M3_29_BWR]
|
||||
board_build.ldscript = nrf52811_bootloader.ld
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-D BUILD_NEWTON_M3_29_BWR
|
||||
-D EPD_DRIVER=SSD1619
|
||||
-Tnrf52811_bootloader.ld
|
||||
build_src_filter =
|
||||
+<*>-<uc_variant_043.cpp>-<uc8179.cpp>-<uc8159.cpp>+<../hal/Newton_M3_nRF52811/*>
|
||||
+<*>-<epd_driver/*>+<../hal/Newton_M3_nRF52811/*>
|
||||
|
||||
[env:Newton_M3_29_VAR1_BWR]
|
||||
board_build.ldscript = nrf52811_bootloader.ld
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-D BUILD_NEWTON_M3_29_BWR
|
||||
-D EPD_DRIVER=UCVARIANT029
|
||||
-Tnrf52811_bootloader.ld
|
||||
build_src_filter =
|
||||
+<*>-<epd_driver/*>+<../hal/Newton_M3_nRF52811/*>
|
||||
|
||||
[env:Newton_M3_43_BWR]
|
||||
board_build.ldscript = nrf52811_bootloader.ld
|
||||
@@ -39,9 +51,10 @@ extra_scripts = post:preparefiles.py
|
||||
-Wunused-macros
|
||||
${env.build_flags}
|
||||
-D BUILD_NEWTON_M3_43_BWR
|
||||
-D EPD_DRIVER=UCVARIANT043
|
||||
-Tnrf52811_bootloader.ld
|
||||
build_src_filter =
|
||||
+<*>-<ssd1619.cpp>-<uc8179.cpp>-<uc8159.cpp>+<../hal/Newton_M3_nRF52811/*>
|
||||
+<*>-<epd_driver/*>+<../hal/Newton_M3_nRF52811/*>
|
||||
|
||||
[env:Newton_M3_60_BWR]
|
||||
board_build.ldscript = nrf52811_bootloader.ld
|
||||
@@ -49,8 +62,9 @@ extra_scripts = post:preparefiles.py
|
||||
${env.build_flags}
|
||||
-Tnrf52811_bootloader.ld
|
||||
-D BUILD_NEWTON_M3_60_BWR
|
||||
-D EPD_DRIVER=UC8159
|
||||
build_src_filter =
|
||||
+<*>-<uc_variant_043.cpp>-<ssd1619.cpp>-<ssd1619.cpp>-<uc8179.cpp>+<../hal/Newton_M3_nRF52811/*>
|
||||
+<*>-<epd_driver/*>+<../hal/Newton_M3_nRF52811/*>
|
||||
|
||||
[env:Newton_M3_75_BWR]
|
||||
board_build.ldscript = nrf52811_bootloader.ld
|
||||
@@ -58,6 +72,7 @@ extra_scripts = post:preparefiles.py
|
||||
${env.build_flags}
|
||||
-Tnrf52811_bootloader.ld
|
||||
-D BUILD_NEWTON_M3_75_BWR
|
||||
-D EPD_DRIVER=UC8179
|
||||
build_src_filter =
|
||||
+<*>-<uc_variant_043.cpp>-<ssd1619.cpp>-<uc8159.cpp>+<../hal/Newton_M3_nRF52811/*>
|
||||
+<*>-<epd_driver/*>+<../hal/Newton_M3_nRF52811/*>
|
||||
|
||||
|
||||
25
ARM_Tag_FW/Newton_M3_nRF52811/src/epd.cpp
Normal file
25
ARM_Tag_FW/Newton_M3_nRF52811/src/epd.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#define SSD1619 0
|
||||
#define UCVARIANT029 1
|
||||
#define UCVARIANT043 2
|
||||
#define UC8159 3
|
||||
#define UC8179 4
|
||||
|
||||
#if EPD_DRIVER == SSD1619
|
||||
#include "epd_driver/ssd1619.cpp"
|
||||
#endif
|
||||
|
||||
#if EPD_DRIVER == UCVARIANT029
|
||||
#include "epd_driver/uc_variant_029.cpp"
|
||||
#endif
|
||||
|
||||
#if EPD_DRIVER == UCVARIANT043
|
||||
#include "epd_driver/uc_variant_043.cpp"
|
||||
#endif
|
||||
|
||||
#if EPD_DRIVER == UC8159
|
||||
#include "epd_driver/uc8159.cpp"
|
||||
#endif
|
||||
|
||||
#if EPD_DRIVER == UC8179
|
||||
#include "epd_driver/uc8179.cpp"
|
||||
#endif
|
||||
@@ -1,30 +1,22 @@
|
||||
#ifndef _JSCREEN_H_
|
||||
#define _JSCREEN_H_
|
||||
#ifndef _EPD_IFACE_H_
|
||||
#define _EPD_IFACE_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define EPD_SSD1619
|
||||
|
||||
#define epdSend spi_write
|
||||
|
||||
#define EPD_LUT_DEFAULT 0
|
||||
#define EPD_LUT_NO_REPEATS 1
|
||||
#define EPD_LUT_FAST_NO_REDS 2
|
||||
#define EPD_LUT_FAST 3
|
||||
#define EPD_LUT_OTA 0x10
|
||||
|
||||
void epdSetup();
|
||||
void epdEnterSleep();
|
||||
|
||||
extern uint8_t dispLutSize;
|
||||
extern uint8_t customLUT[];
|
||||
|
||||
void draw();
|
||||
void drawNoWait();
|
||||
void drawWithSleep();
|
||||
void epdWaitRdy();
|
||||
|
||||
#define EPD_LUT_DEFAULT 0
|
||||
#define EPD_LUT_NO_REPEATS 1
|
||||
#define EPD_LUT_FAST_NO_REDS 2
|
||||
#define EPD_LUT_FAST 3
|
||||
|
||||
void selectLUT(uint8_t lut);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "ssd1619.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
@@ -64,21 +62,8 @@
|
||||
digitalWrite(EPD_DC, HIGH); \
|
||||
} while (0)
|
||||
|
||||
extern void dump(const uint8_t *a, const uint16_t l); // remove me when done
|
||||
|
||||
static uint8_t currentLut = 0;
|
||||
uint8_t dispLutSize = 0; // we'll need to expose this in the 'capabilities' flag
|
||||
|
||||
static bool isInited = false;
|
||||
|
||||
#define LUT_BUFFER_SIZE 256
|
||||
static uint8_t waveformbuffer[LUT_BUFFER_SIZE];
|
||||
uint8_t customLUT[LUT_BUFFER_SIZE] = {0};
|
||||
|
||||
struct waveform10 *waveform10 = (struct waveform10 *)waveformbuffer; // holds the LUT/waveform
|
||||
struct waveform *waveform7 = (struct waveform *)waveformbuffer; // holds the LUT/waveform
|
||||
struct waveform12 *waveform12 = (struct waveform12 *)waveformbuffer; // holds the LUT/waveform
|
||||
|
||||
static void commandReadBegin(uint8_t cmd) {
|
||||
epdSelect();
|
||||
markCommand();
|
||||
@@ -147,6 +132,16 @@ void setPosXY(uint16_t x, uint16_t y) {
|
||||
epdWrite(CMD_YSTART_POS, 2, (y)&0xff, (y) >> 8);
|
||||
}
|
||||
|
||||
|
||||
void selectLUT(uint8_t lut) {
|
||||
// implement alternative LUTs here. Currently just reset the watchdog to two minutes,
|
||||
// to ensure it doesn't reset during the much longer bootup procedure
|
||||
lut += 1; // make the compiler a happy camper
|
||||
wdt120s();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void epdEnterSleep() {
|
||||
digitalWrite(EPD_RST, LOW);
|
||||
delay(10);
|
||||
@@ -174,7 +169,6 @@ void epdSetup() {
|
||||
epdWrite(CMD_ACTIVATION, 0);
|
||||
epdBusyWaitFalling(10000);
|
||||
isInited = true;
|
||||
currentLut = EPD_LUT_DEFAULT;
|
||||
}
|
||||
static uint8_t epdGetStatus() {
|
||||
uint8_t sta;
|
||||
@@ -184,188 +178,6 @@ static uint8_t epdGetStatus() {
|
||||
return sta;
|
||||
}
|
||||
|
||||
void loadFixedTempOTPLUT() {
|
||||
shortCommand1(0x18, 0x48); // external temp sensor
|
||||
shortCommand2(0x1A, 0x05, 0x00); // < temp register
|
||||
shortCommand1(CMD_DISP_UPDATE_CTRL2, 0xB1); // mode 1 (i2C)
|
||||
shortCommand(CMD_ACTIVATION);
|
||||
epdBusyWaitFalling(1000);
|
||||
}
|
||||
static void writeLut() {
|
||||
commandBegin(CMD_WRITE_LUT);
|
||||
if (dispLutSize == 12) {
|
||||
for (uint8_t i = 0; i < 153; i++)
|
||||
epdSend(waveformbuffer[i]);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < (dispLutSize * 10); i++)
|
||||
epdSend(waveformbuffer[i]);
|
||||
}
|
||||
commandEnd();
|
||||
}
|
||||
static void readLut() {
|
||||
commandReadBegin(0x33);
|
||||
for (uint16_t c = 0; c < LUT_BUFFER_SIZE; c++) {
|
||||
waveformbuffer[c] = epdReadByte();
|
||||
}
|
||||
commandReadEnd();
|
||||
}
|
||||
static uint8_t getLutSize() {
|
||||
uint8_t ref = 0;
|
||||
for (uint8_t c = (LUT_BUFFER_SIZE - 4); c > 16; c--) {
|
||||
uint8_t check = waveformbuffer[c];
|
||||
for (uint8_t d = 1; d < 4; d++) {
|
||||
if (waveformbuffer[c + d] != check) {
|
||||
ref = c;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
end:;
|
||||
return ref + 1;
|
||||
}
|
||||
static void lutGroupDisable(uint8_t group) {
|
||||
switch (dispLutSize) {
|
||||
case 7:
|
||||
memset(&(waveform7->group[group]), 0x00, 5);
|
||||
break;
|
||||
case 10:
|
||||
memset(&(waveform10->group[group]), 0x00, 5);
|
||||
break;
|
||||
case 12:
|
||||
memset(&(waveform12->group[group]), 0x00, sizeof(waveform12->group[0]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
static void lutGroupSpeedup(uint8_t group, uint8_t speed) {
|
||||
switch (dispLutSize) {
|
||||
case 7:
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
waveform7->group[group].phaselength[i] = 1 + (waveform7->group[group].phaselength[i] / speed);
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
waveform10->group[group].phaselength[i] = 1 + (waveform10->group[group].phaselength[i] / speed);
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
waveform12->group[group].tp0a = 1 + (waveform12->group[group].tp0a / speed);
|
||||
waveform12->group[group].tp0b = 1 + (waveform12->group[group].tp0b / speed);
|
||||
waveform12->group[group].tp0c = 1 + (waveform12->group[group].tp0c / speed);
|
||||
waveform12->group[group].tp0d = 1 + (waveform12->group[group].tp0d / speed);
|
||||
break;
|
||||
}
|
||||
}
|
||||
static void lutGroupRepeat(uint8_t group, uint8_t repeat) {
|
||||
switch (dispLutSize) {
|
||||
case 7:
|
||||
waveform7->group[group].repeat = repeat;
|
||||
break;
|
||||
case 10:
|
||||
waveform10->group[group].repeat = repeat;
|
||||
break;
|
||||
case 12:
|
||||
waveform12->group[group].repeat = repeat;
|
||||
break;
|
||||
}
|
||||
}
|
||||
static void lutGroupRepeatReduce(uint8_t group, uint8_t factor) {
|
||||
switch (dispLutSize) {
|
||||
case 7:
|
||||
waveform7->group[group].repeat = waveform7->group[group].repeat / factor;
|
||||
break;
|
||||
case 10:
|
||||
waveform10->group[group].repeat = waveform10->group[group].repeat / factor;
|
||||
break;
|
||||
case 12:
|
||||
waveform12->group[group].repeat = waveform12->group[group].repeat / factor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
void selectLUT(uint8_t lut) {
|
||||
if (currentLut == lut) {
|
||||
// return;
|
||||
}
|
||||
|
||||
// Handling if we received an OTA LUT
|
||||
if (lut == EPD_LUT_OTA) {
|
||||
memcpy(waveformbuffer, customLUT, dispLutSize * 10);
|
||||
writeLut();
|
||||
currentLut = lut;
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentLut != EPD_LUT_DEFAULT) {
|
||||
// load the 'default' LUT for the current temperature in the EPD lut register
|
||||
shortCommand1(CMD_DISP_UPDATE_CTRL2, 0xB1); // mode 1?
|
||||
shortCommand(CMD_ACTIVATION);
|
||||
epdBusyWaitFalling(1000);
|
||||
}
|
||||
|
||||
currentLut = lut;
|
||||
|
||||
// if we're going to be using the default LUT, we're done here.
|
||||
if (lut == EPD_LUT_DEFAULT) {
|
||||
return;
|
||||
}
|
||||
|
||||
// download the current LUT from the waveform buffer
|
||||
readLut();
|
||||
|
||||
if (dispLutSize == 0) {
|
||||
dispLutSize = getLutSize();
|
||||
dispLutSize /= 10;
|
||||
printf("lut size = %d\n", dispLutSize);
|
||||
dispLutSize = 12;
|
||||
#ifdef PRINT_LUT
|
||||
dump(waveformbuffer, LUT_BUFFER_SIZE);
|
||||
#endif
|
||||
memcpy(customLUT, waveformbuffer, LUT_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
switch (lut) {
|
||||
default:
|
||||
case EPD_LUT_NO_REPEATS:
|
||||
lutGroupDisable(LUTGROUP_NEGATIVE);
|
||||
lutGroupDisable(LUTGROUP_FASTBLINK);
|
||||
lutGroupRepeat(LUTGROUP_SLOWBLINK, 0);
|
||||
lutGroupSpeedup(LUTGROUP_SET, 2);
|
||||
lutGroupSpeedup(LUTGROUP_IMPROVE_SHARPNESS, 2);
|
||||
lutGroupRepeatReduce(LUTGROUP_IMPROVE_SHARPNESS, 2);
|
||||
lutGroupSpeedup(LUTGROUP_IMPROVE_REDS, 2);
|
||||
lutGroupRepeatReduce(LUTGROUP_IMPROVE_REDS, 2);
|
||||
lutGroupDisable(LUTGROUP_UNUSED);
|
||||
break;
|
||||
case EPD_LUT_FAST_NO_REDS:
|
||||
lutGroupDisable(LUTGROUP_NEGATIVE);
|
||||
lutGroupDisable(LUTGROUP_FASTBLINK);
|
||||
lutGroupDisable(LUTGROUP_SLOWBLINK);
|
||||
lutGroupSpeedup(LUTGROUP_SET, 2);
|
||||
lutGroupDisable(LUTGROUP_IMPROVE_REDS);
|
||||
lutGroupDisable(LUTGROUP_IMPROVE_SHARPNESS);
|
||||
lutGroupDisable(LUTGROUP_UNUSED);
|
||||
break;
|
||||
case EPD_LUT_FAST:
|
||||
lutGroupDisable(LUTGROUP_NEGATIVE);
|
||||
lutGroupDisable(LUTGROUP_FASTBLINK);
|
||||
lutGroupDisable(LUTGROUP_SLOWBLINK);
|
||||
lutGroupRepeat(LUTGROUP_SET, 1);
|
||||
lutGroupSpeedup(LUTGROUP_SET, 2);
|
||||
lutGroupDisable(LUTGROUP_IMPROVE_SHARPNESS);
|
||||
lutGroupDisable(LUTGROUP_IMPROVE_REDS);
|
||||
lutGroupDisable(LUTGROUP_UNUSED);
|
||||
break;
|
||||
}
|
||||
|
||||
if (dispLutSize == 10) {
|
||||
lutGroupDisable(LUTGROUP_UNUSED);
|
||||
lutGroupDisable(LUTGROUP_UNKNOWN);
|
||||
lutGroupDisable(LUTGROUP_UNUSED3);
|
||||
lutGroupDisable(LUTGROUP_UNUSED4);
|
||||
}
|
||||
writeLut();
|
||||
}
|
||||
|
||||
void epdWriteDisplayData() {
|
||||
setWindowX(SCREEN_XOFFSET, SCREEN_WIDTH + SCREEN_XOFFSET);
|
||||
setPosXY(SCREEN_XOFFSET, 0);
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "uc8159.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "uc8179.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
128
ARM_Tag_FW/Newton_M3_nRF52811/src/epd_driver/uc_variant_029.cpp
Normal file
128
ARM_Tag_FW/Newton_M3_nRF52811/src/epd_driver/uc_variant_029.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
#include <Arduino.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "hal.h"
|
||||
#include "lut.h"
|
||||
#include "settings.h"
|
||||
#include "wdt.h"
|
||||
#include "drawing.h"
|
||||
|
||||
#define EPD_CMD_POWER_OFF 0x02
|
||||
#define EPD_CMD_POWER_ON 0x04
|
||||
#define EPD_CMD_BOOSTER_SOFT_START 0x06
|
||||
#define EPD_CMD_DEEP_SLEEP 0x07
|
||||
#define EPD_CMD_DISPLAY_START_TRANSMISSION_DTM1 0x10
|
||||
#define EPD_CMD_DISPLAY_REFRESH 0x12
|
||||
#define EPD_CMD_DISPLAY_START_TRANSMISSION_DTM2 0x13
|
||||
#define EPD_CMD_VCOM_INTERVAL 0x50
|
||||
#define EPD_CMD_RESOLUTION_SETTING 0x61
|
||||
#define EPD_CMD_UNKNOWN 0xF8
|
||||
|
||||
void epdEnterSleep() {
|
||||
epd_cmd(EPD_CMD_POWER_OFF);
|
||||
epdBusyWaitRising(50000);
|
||||
epdWrite(EPD_CMD_DEEP_SLEEP, 1, 0xA5);
|
||||
delay(200);
|
||||
delay(1);
|
||||
}
|
||||
|
||||
void epdSetup() {
|
||||
epdReset();
|
||||
epdWrite(0x4D, 1, 0x55);
|
||||
epdWrite(0xF3, 1, 0x0A);
|
||||
epdWrite(0x31, 1, 0x00);
|
||||
epdWrite(0x06, 3, 0xE5, 0x35, 0x3C);
|
||||
epdWrite(0x50, 1, 0x57);
|
||||
epdWrite(0x00, 2, 0x03 | 0x04, 0x09);
|
||||
}
|
||||
|
||||
void epdWriteDisplayData() {
|
||||
// send a dummy byte. Don't ask me why, it's what she likes. She'll sometimes display garbage on the b/w framebuffer if she doesn't get the dummy byte.
|
||||
epd_data(0x00);
|
||||
|
||||
// this display expects two entire framebuffers worth of data to be written, one for b/w and one for red
|
||||
uint8_t* buf[2] = {0, 0}; // this will hold pointers to odd/even data lines
|
||||
for (uint8_t c = 0; c < 2; c++) {
|
||||
if (c == 0) epd_cmd(EPD_CMD_DISPLAY_START_TRANSMISSION_DTM1);
|
||||
if (c == 1) epd_cmd(EPD_CMD_DISPLAY_START_TRANSMISSION_DTM2);
|
||||
markData();
|
||||
epdSelect();
|
||||
for (uint16_t curY = 0; curY < SCREEN_HEIGHT; curY += 2) {
|
||||
// Get 'even' screen line
|
||||
buf[0] = (uint8_t*)calloc(SCREEN_WIDTH / 8, 1);
|
||||
drawItem::renderDrawLine(buf[0], curY, c);
|
||||
if (c == 0) {
|
||||
for (uint8_t c = 0; c < SCREEN_WIDTH / 8; c++) {
|
||||
buf[0][c] = ~buf[0][c];
|
||||
}
|
||||
}
|
||||
|
||||
// on the first pass, the second (buf[1]) buffer is unused, so we don't have to wait for it to flush to the display / free it
|
||||
if (buf[1]) {
|
||||
// wait for 'odd' display line to finish writing to the screen
|
||||
epdSPIWait();
|
||||
free(buf[1]);
|
||||
}
|
||||
|
||||
// start transfer of even data line to the screen
|
||||
epdSPIAsyncWrite(buf[0], (SCREEN_WIDTH / 8));
|
||||
|
||||
// Get 'odd' screen display line
|
||||
buf[1] = (uint8_t*)calloc(SCREEN_WIDTH / 8, 1);
|
||||
drawItem::renderDrawLine(buf[1], curY + 1, c);
|
||||
if (c == 0) {
|
||||
for (uint8_t c = 0; c < SCREEN_WIDTH / 8; c++) {
|
||||
buf[1][c] = ~buf[1][c];
|
||||
}
|
||||
}
|
||||
|
||||
// wait until the 'even' data has finished writing
|
||||
epdSPIWait();
|
||||
free(buf[0]);
|
||||
|
||||
// start transfer of the 'odd' data line
|
||||
epdSPIAsyncWrite(buf[1], (SCREEN_WIDTH / 8));
|
||||
}
|
||||
// check if this was the first pass. If it was, we'll need to wait until the last display line finished writing
|
||||
if (c == 0) {
|
||||
epdSPIWait();
|
||||
epdDeselect();
|
||||
free(buf[1]);
|
||||
buf[1] = nullptr;
|
||||
}
|
||||
}
|
||||
// flush the draw list, make sure items don't appear on subsequent screens
|
||||
drawItem::flushDrawItems();
|
||||
|
||||
// wait until the last line of display has finished writing and clean our stuff up
|
||||
epdSPIWait();
|
||||
epdDeselect();
|
||||
if (buf[1]) free(buf[1]);
|
||||
}
|
||||
|
||||
void selectLUT(uint8_t lut) {
|
||||
// implement alternative LUTs here. Currently just reset the watchdog to two minutes,
|
||||
// to ensure it doesn't reset during the much longer bootup procedure
|
||||
lut += 1; // make the compiler a happy camper
|
||||
wdt120s();
|
||||
return;
|
||||
}
|
||||
|
||||
void draw() {
|
||||
drawNoWait();
|
||||
epdBusyWaitRising(50000);
|
||||
}
|
||||
void drawNoWait() {
|
||||
epdWriteDisplayData();
|
||||
epd_cmd(EPD_CMD_POWER_ON);
|
||||
epdBusyWaitRising(200);
|
||||
epd_cmd(EPD_CMD_DISPLAY_REFRESH);
|
||||
}
|
||||
|
||||
void epdWaitRdy() {
|
||||
epdBusyWaitRising(50000);
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "uc_variant_043.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
@@ -26,10 +24,7 @@
|
||||
|
||||
void epdEnterSleep() {
|
||||
epd_cmd(EPD_CMD_POWER_OFF);
|
||||
epdBusyWaitRising(50000);
|
||||
epdWrite(EPD_CMD_DEEP_SLEEP, 1, 0xA5);
|
||||
delay(200);
|
||||
delay(1);
|
||||
}
|
||||
|
||||
void epdSetup() {
|
||||
@@ -900,39 +900,6 @@ bool processAvailDataInfo(struct AvailDataInfo *avail) {
|
||||
return true;
|
||||
break;
|
||||
case DATATYPE_CUSTOM_LUT_OTA:
|
||||
// Handle data for the NFC IC (if we have it)
|
||||
|
||||
// check if we actually have the capability to do OTA Luts
|
||||
if (!(capabilities & CAPABILITY_SUPPORTS_CUSTOM_LUTS)) {
|
||||
// looks like we don't. mark as complete and then bail!
|
||||
powerUp(INIT_RADIO);
|
||||
sendXferComplete();
|
||||
powerDown(INIT_RADIO);
|
||||
return true;
|
||||
}
|
||||
#ifdef EPD_SSD1619
|
||||
printf("OTA LUT received\n");
|
||||
if (curDataInfo.dataSize == 0 && !memcmp((const void *)&avail->dataVer, (const void *)&curDataInfo.dataVer, 8)) {
|
||||
printf("this was the same as the last transfer, disregard\n");
|
||||
powerUp(INIT_RADIO);
|
||||
sendXferComplete();
|
||||
powerDown(INIT_RADIO);
|
||||
return true;
|
||||
}
|
||||
curBlock.blockId = 0;
|
||||
memcpy(&(curBlock.ver), &(avail->dataVer), 8);
|
||||
curBlock.type = avail->dataType;
|
||||
memcpy(&curDataInfo, (void *)avail, sizeof(struct AvailDataInfo));
|
||||
wdt10s();
|
||||
if (getDataBlock(avail->dataSize)) {
|
||||
curDataInfo.dataSize = 0; // mark as transfer not pending
|
||||
memcpy(customLUT, sizeof(struct blockData) + blockXferBuffer, dispLutSize * 10);
|
||||
powerUp(INIT_RADIO);
|
||||
sendXferComplete();
|
||||
powerDown(INIT_RADIO);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "lut.h"
|
||||
#include "powermgt.h"
|
||||
#include "proto.h"
|
||||
|
||||
#include "settings.h"
|
||||
#include "syncedproto.h" // for APmac / Channel
|
||||
#include "hal.h"
|
||||
@@ -33,21 +33,22 @@ bool noAPShown = false;
|
||||
|
||||
void addOverlay() {
|
||||
if (currentChannel == 0) {
|
||||
drawMask(SCREEN_WIDTH - 27, 5, 22, 22, COLOR_BLACK);
|
||||
drawMask(SCREEN_WIDTH - 27, 5, 22, 22, COLOR_RED);
|
||||
drawRoundedRectangle(SCREEN_WIDTH - 28, 4, 24, 24, COLOR_RED);
|
||||
addBufferedImage(SCREEN_WIDTH - 24, 8, COLOR_BLACK, rotation::ROTATE_0, ant, DRAW_NORMAL);
|
||||
addBufferedImage(SCREEN_WIDTH - 16, 15, COLOR_RED, rotation::ROTATE_0, cross, DRAW_NORMAL);
|
||||
drawMask(UI_SCREEN_WIDTH - 27, 5, 22, 22, COLOR_BLACK);
|
||||
drawMask(UI_SCREEN_WIDTH - 27, 5, 22, 22, COLOR_RED);
|
||||
drawRoundedRectangle(UI_SCREEN_WIDTH - 28, 4, 24, 24, COLOR_RED);
|
||||
addBufferedImage(UI_SCREEN_WIDTH - 24, 8, COLOR_BLACK, rotation::ROTATE_0, ant, DRAW_NORMAL);
|
||||
addBufferedImage(UI_SCREEN_WIDTH - 16, 15, COLOR_RED, rotation::ROTATE_0, cross, DRAW_NORMAL);
|
||||
noAPShown = true;
|
||||
} else {
|
||||
noAPShown = false;
|
||||
}
|
||||
|
||||
lowBattery = true;
|
||||
if (lowBattery) {
|
||||
drawMask(SCREEN_WIDTH - 27, SCREEN_HEIGHT - 26, 22, 22, COLOR_BLACK);
|
||||
drawMask(SCREEN_WIDTH - 27, SCREEN_HEIGHT - 26, 22, 22, COLOR_RED);
|
||||
drawRoundedRectangle(SCREEN_WIDTH - 28, SCREEN_HEIGHT - 27, 24, 24, COLOR_RED);
|
||||
addBufferedImage(SCREEN_WIDTH - 24, SCREEN_HEIGHT - 19, COLOR_BLACK, rotation::ROTATE_0, battery, DRAW_NORMAL);
|
||||
drawMask(UI_SCREEN_WIDTH - 27, UI_SCREEN_HEIGHT - 26, 22, 22, COLOR_BLACK);
|
||||
drawMask(UI_SCREEN_WIDTH - 27, UI_SCREEN_HEIGHT - 26, 22, 22, COLOR_RED);
|
||||
drawRoundedRectangle(UI_SCREEN_WIDTH - 28, UI_SCREEN_HEIGHT - 27, 24, 24, COLOR_RED);
|
||||
addBufferedImage(UI_SCREEN_WIDTH - 24, UI_SCREEN_HEIGHT - 19, COLOR_BLACK, rotation::ROTATE_0, battery, DRAW_NORMAL);
|
||||
|
||||
lowBatteryShown = true;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user