Skip to content

Commit

Permalink
Printf fixing and Prepairing of new display types, driver itselfs nee…
Browse files Browse the repository at this point in the history
…ds to be tweaked,

The new higher resolution is too high for the RAM, so needs some different driving overall
  • Loading branch information
atc1441 committed Dec 1, 2022
1 parent 7fb07b0 commit 6b6d1ea
Show file tree
Hide file tree
Showing 11 changed files with 603 additions and 10 deletions.
Binary file modified Firmware/ATC_Paper.bin
Binary file not shown.
2 changes: 2 additions & 0 deletions Firmware/components/application/print/u_printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@

#include "drivers.h"
extern int putchar(int c);
extern int putchar_custom(int c);
static void printchar(char **str, int c) {
if (str) {
**str = c;
++(*str);
} else
(void) putchar(c);
(void) putchar_custom(c);
}

#define PAD_RIGHT 1
Expand Down
28 changes: 26 additions & 2 deletions Firmware/src/epd.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "epd_spi.h"
#include "epd_bw_213.h"
#include "epd_bwr_213.h"
#include "epd_bwr_350.h"
#include "epd_bwy_350.h"
#include "epd_bw_213_ice.h"
#include "epd_bwr_154.h"
#include "drivers.h"
Expand All @@ -20,8 +22,8 @@ extern const uint8_t ucMirror[];
#include "font16.h"
#include "font30.h"

RAM uint8_t epd_model = 0; // 0 = Undetected, 1 = BW213, 2 = BWR213, 3 = BWR154, 4 = BW213ICE
const char *epd_model_string[] = {"NC", "BW213", "BWR213", "BWR154", "213ICE"};
RAM uint8_t epd_model = 0; // 0 = Undetected, 1 = BW213, 2 = BWR213, 3 = BWR154, 4 = BW213ICE, 5 = BWR350
const char *epd_model_string[] = {"NC", "BW213", "BWR213", "BWR154", "213ICE", "BWR350", "BWY350"};
RAM uint8_t epd_update_state = 0;

const char *BLE_conn_string[] = {"", "B"};
Expand Down Expand Up @@ -100,6 +102,10 @@ _attribute_ram_code_ uint8_t EPD_read_temp(void)
epd_temperature = EPD_BWR_154_read_temp();
else if (epd_model == 4)
epd_temperature = EPD_BW_213_ice_read_temp();
else if (epd_model == 5)
epd_temperature = EPD_BWR_350_read_temp();
else if (epd_model == 6)
epd_temperature = EPD_BWY_350_read_temp();

EPD_POWER_OFF();

Expand Down Expand Up @@ -131,6 +137,10 @@ _attribute_ram_code_ void EPD_Display(unsigned char *image, int size, uint8_t fu
epd_temperature = EPD_BWR_154_Display(image, size, full_or_partial);
else if (epd_model == 4)
epd_temperature = EPD_BW_213_ice_Display(image, size, full_or_partial);
else if (epd_model == 5)
epd_temperature = EPD_BWR_350_Display(image, size, full_or_partial);
else if (epd_model == 6)
epd_temperature = EPD_BWY_350_Display(image, size, full_or_partial);

epd_temperature_is_read = 1;
epd_update_state = 1;
Expand All @@ -149,6 +159,10 @@ _attribute_ram_code_ void epd_set_sleep(void)
EPD_BWR_154_set_sleep();
else if (epd_model == 4)
EPD_BW_213_ice_set_sleep();
else if (epd_model == 5)
EPD_BWR_350_set_sleep();
else if (epd_model == 6)
EPD_BWY_350_set_sleep();

EPD_POWER_OFF();
epd_update_state = 0;
Expand Down Expand Up @@ -262,6 +276,16 @@ _attribute_ram_code_ void epd_display(uint32_t time_is, uint16_t battery_mv, int
resolution_w = 212;
resolution_h = 104;
}
else if (epd_model == 5)
{// Just as placeholder right now, needs a complete different driving because of RAM limits
resolution_w = 250;
resolution_h = 128; // 122 real pixel, but needed to have a full byte
}
else if (epd_model == 6)
{// Just as placeholder right now, needs a complete different driving because of RAM limits
resolution_w = 250;
resolution_h = 128; // 122 real pixel, but needed to have a full byte
}

obdCreateVirtualDisplay(&obd, resolution_w, resolution_h, epd_temp);
obdFill(&obd, 0, 0); // fill with white
Expand Down
277 changes: 277 additions & 0 deletions Firmware/src/epd_bwr_350.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
#include <stdint.h>
#include "tl_common.h"
#include "main.h"
#include "epd.h"
#include "epd_spi.h"
#include "epd_bwr_350.h"
#include "drivers.h"
#include "stack/ble/ble.h"

// SSD1675 mixed with SSD1680 EPD Controller

#define BWR_350_Len 50
uint8_t LUT_bwr_350_part[] = {

0x01, 0x10, 0x18, 0x01, 0x32, 0x02, 0x01, 0x10, 0x08, 0x01, 0x03, 0x02,
0x01, 0x01, 0x01, 0x0A, 0x05, 0x0A, 0x0F, 0x01, 0x01, 0x01, 0x14, 0x0F,
0x02, 0x02, 0x01, 0x14, 0x01, 0x02, 0x02, 0x04, 0x02, 0x14, 0x12, 0x01,
0x0A, 0x0F, 0x01, 0x02, 0x01, 0x01, 0x07, 0x05, 0x00, 0x22, 0x02, 0x01,
0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x50, 0x18, 0x01,
0x72, 0x02, 0x01, 0x10, 0x88, 0x01, 0x43,
0x02, 0x01, 0x01, 0x01, 0x4A, 0x85, 0x4A,
0x8F, 0x01, 0x01, 0x01, 0x94, 0x8F, 0x82,
0x42, 0x01, 0x14, 0x01, 0x82, 0x42, 0x84,
0x42, 0x14, 0x12, 0x01, 0x4A, 0x4F, 0x01,
0x02, 0x01, 0x01, 0x07, 0x85, 0x00, 0xE2,
0x02, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x50, 0x58, 0x81,
0x72, 0x02, 0x01, 0x10, 0x88, 0x01, 0x43,
0x42, 0x01, 0x01, 0x01, 0x4A, 0x85, 0x4A,
0x8F, 0x01, 0x01, 0x01, 0x94, 0x8F, 0x82,
0x42, 0x01, 0x14, 0x01, 0x82, 0x42, 0x84,
0x42, 0x14, 0x12, 0x01, 0x4A, 0x4F, 0x01,
0x02, 0x01, 0x01, 0x07, 0x85, 0x00, 0x22,
0x02, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x50, 0x58, 0x01,
0x72, 0x02, 0x01, 0x10, 0x88, 0x81, 0x43,
0x02, 0x01, 0x01, 0x01, 0x4A, 0x85, 0x4A,
0x8F, 0x01, 0x01, 0x01, 0x94, 0x8F, 0x82,
0x42, 0x01, 0x14, 0x01, 0x82, 0x42, 0x84,
0x42, 0x14, 0x12, 0x01, 0x4A, 0x4F, 0x01,
0x82, 0x01, 0x01, 0x07, 0x05, 0x00, 0x22,
0x42, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01,
0x02, 0x00, 0x00,
0x22, 0x17, 0x41, 0xA8, 0x32, 0x50
};

#define EPD_BWR_350_test_pattern 0xA5
_attribute_ram_code_ uint8_t EPD_BWR_350_detect(void)
{
// SW Reset
EPD_WriteCmd(0x12);
WaitMs(10);

EPD_WriteCmd(0x32);
int i;
for (i = 0; i < 153; i++)// This model has a 159 bytes LUT storage so we test for that
{
EPD_WriteData(EPD_BWR_350_test_pattern);
}
EPD_WriteCmd(0x33);
for (i = 0; i < 153; i++)
{
if(EPD_SPI_read() != EPD_BWR_350_test_pattern)
return 0;
}
return 1;
}

_attribute_ram_code_ uint8_t EPD_BWR_350_read_temp(void)
{
uint8_t epd_temperature = 0 ;

// SW Reset
EPD_WriteCmd(0x12);

EPD_CheckStatus_inverted(100);

// Set Analog Block control
EPD_WriteCmd(0x74);
EPD_WriteData(0x54);
// Set Digital Block control
EPD_WriteCmd(0x7E);
EPD_WriteData(0x3B);

// Booster soft start
EPD_WriteCmd(0x0C);
EPD_WriteData(0x8B);
EPD_WriteData(0x9C);
EPD_WriteData(0x96);
EPD_WriteData(0x0F);

// Driver output control
EPD_WriteCmd(0x01);
EPD_WriteData(0x28);
EPD_WriteData(0x01);
EPD_WriteData(0x01);

// Data entry mode setting
EPD_WriteCmd(0x11);
EPD_WriteData(0x01);

// Set RAM X- Address Start/End
EPD_WriteCmd(0x44);
EPD_WriteData(0x00);
EPD_WriteData(0x0F);

// Set RAM Y- Address Start/End
EPD_WriteCmd(0x45);
EPD_WriteData(0x28);
EPD_WriteData(0x01);
EPD_WriteData(0x2E);
EPD_WriteData(0x00);

// Border waveform control
EPD_WriteCmd(0x3C);
EPD_WriteData(0x05);

// Display update control
EPD_WriteCmd(0x21);
EPD_WriteData(0x00);
EPD_WriteData(0x80);

// Temperature sensor control
EPD_WriteCmd(0x18);
EPD_WriteData(0x80);

// Display update control
EPD_WriteCmd(0x22);
EPD_WriteData(0xB1);

// Master Activation
EPD_WriteCmd(0x20);

EPD_CheckStatus_inverted(100);

// Temperature sensor read from register
EPD_WriteCmd(0x1B);
epd_temperature = EPD_SPI_read();
EPD_SPI_read();

WaitMs(5);

// deep sleep
EPD_WriteCmd(0x10);
EPD_WriteData(0x01);

return epd_temperature;
}

_attribute_ram_code_ uint8_t EPD_BWR_350_Display(unsigned char *image, int size, uint8_t full_or_partial)
{
uint8_t epd_temperature = 0 ;

// SW Reset
EPD_WriteCmd(0x12);

EPD_CheckStatus_inverted(100);

// Set Analog Block control
EPD_WriteCmd(0x74);
EPD_WriteData(0x54);
// Set Digital Block control
EPD_WriteCmd(0x7E);
EPD_WriteData(0x3B);

// Booster soft start
EPD_WriteCmd(0x0C);
EPD_WriteData(0x8B);
EPD_WriteData(0x9C);
EPD_WriteData(0x96);
EPD_WriteData(0x0F);

// Driver output control
EPD_WriteCmd(0x01);
EPD_WriteData(0x28);
EPD_WriteData(0x01);
EPD_WriteData(0x01);

// Data entry mode setting
EPD_WriteCmd(0x11);
EPD_WriteData(0x01);

// Set RAM X- Address Start/End
EPD_WriteCmd(0x44);
EPD_WriteData(0x00);
EPD_WriteData(0x0F);

// Set RAM Y- Address Start/End
EPD_WriteCmd(0x45);
EPD_WriteData(0x28);
EPD_WriteData(0x01);
EPD_WriteData(0x2E);
EPD_WriteData(0x00);

// Border waveform control
EPD_WriteCmd(0x3C);
EPD_WriteData(0x05);

// Display update control
EPD_WriteCmd(0x21);
EPD_WriteData(0x00);
EPD_WriteData(0x80);

// Temperature sensor control
EPD_WriteCmd(0x18);
EPD_WriteData(0x80);

// Display update control
EPD_WriteCmd(0x22);
EPD_WriteData(0xB1);

// Master Activation
EPD_WriteCmd(0x20);

EPD_CheckStatus_inverted(100);

// Temperature sensor read from register
EPD_WriteCmd(0x1B);
epd_temperature = EPD_SPI_read();
EPD_SPI_read();

WaitMs(5);

// Set RAM X address
EPD_WriteCmd(0x4E);
EPD_WriteData(0x00);

// Set RAM Y address
EPD_WriteCmd(0x4F);
EPD_WriteData(0x28);
EPD_WriteData(0x01);

EPD_LoadImage(image, size, 0x24);

// Set RAM X address
EPD_WriteCmd(0x4E);
EPD_WriteData(0x00);

// Set RAM Y address
EPD_WriteCmd(0x4F);
EPD_WriteData(0x28);
EPD_WriteData(0x01);

EPD_WriteCmd(0x26);// RED Color TODO make something out of it :)
int i;
for (i = 0; i < size; i++)
{
EPD_WriteData(0x00);
}

if (!full_or_partial)
{
EPD_WriteCmd(0x32);
for (i = 0; i < sizeof(LUT_bwr_350_part); i++)
{
EPD_WriteData(LUT_bwr_350_part[i]);
}
}

// Display update control
EPD_WriteCmd(0x22);
EPD_WriteData(0xC7);

// Master Activation
EPD_WriteCmd(0x20);

return epd_temperature;
}

_attribute_ram_code_ void EPD_BWR_350_set_sleep(void)
{
// deep sleep
EPD_WriteCmd(0x10);
EPD_WriteData(0x01);

}
6 changes: 6 additions & 0 deletions Firmware/src/epd_bwr_350.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

uint8_t EPD_BWR_350_detect(void);
uint8_t EPD_BWR_350_read_temp(void);
uint8_t EPD_BWR_350_Display(unsigned char *image, int size, uint8_t full_or_partial);
void EPD_BWR_350_set_sleep(void);
Loading

0 comments on commit 6b6d1ea

Please sign in to comment.