From 03692bc44b21f768f5109b6608dc5e939d264b83 Mon Sep 17 00:00:00 2001 From: true Date: Sat, 4 Nov 2023 09:59:25 -0700 Subject: [PATCH] Remove unneeded files --- include/gc9a01.h | 36 ------ include/sin7.h | 43 ------- src/gc9a01.c | 316 ----------------------------------------------- src/sin7.c | 108 ---------------- 4 files changed, 503 deletions(-) delete mode 100644 include/gc9a01.h delete mode 100644 include/sin7.h delete mode 100644 src/gc9a01.c delete mode 100644 src/sin7.c diff --git a/include/gc9a01.h b/include/gc9a01.h deleted file mode 100644 index 008bc7c..0000000 --- a/include/gc9a01.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef __GC9A01_H -#define __GC9A01_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// Hardware abstraction layer -// Should be defined by the user of the library -void GC9A01_set_reset(uint8_t val); -void GC9A01_set_data_command(uint8_t val); -void GC9A01_set_chip_select(uint8_t val); -void GC9A01_delay(uint16_t ms); -void GC9A01_spi_tx(uint8_t *data, size_t len); - -struct GC9A01_point { - uint16_t X, Y; -}; - -struct GC9A01_frame { - struct GC9A01_point start, end; -}; - -void GC9A01_init(void); -void GC9A01_set_frame(struct GC9A01_frame frame); -void GC9A01_write(uint8_t *data, size_t len); -void GC9A01_write_continue(uint8_t *data, size_t len); - -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file diff --git a/include/sin7.h b/include/sin7.h deleted file mode 100644 index 98b2b34..0000000 --- a/include/sin7.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Example for a interpolated sine/cosine table lookup - * - * modified by true to work in 8 bits, and to fix cos7 function - * - */ - -#ifndef INC_MATH_SIN7_H_ -#define INC_MATH_SIN7_H_ - - - -#include - - - -/** - * Sine calculation using interpolated table lookup. - * Instead of radians or degrees we use "turns" here. Means this - * sine does NOT return one phase for 0 to 2*PI, but for 0 to 1. - * Input: -1 to 1 as int8 "Q7" == -128 to 127. - * Output: -1 to 1 as int8 "Q7" == -128 to 127. - * - * @param int8_t angle Q7 - * @return int8_t Q7 - */ -int8_t sin7(int8_t angle); - -/** - * Cosine calculation using interpolated table lookup. - * Instead of radians or degrees we use "turns" here. Means this - * cosine does NOT return one phase for 0 to 2*PI, but for 0 to 1. - * Input: -1 to 1 as int8 "Q7" == -128 to 127. - * Output: -1 to 1 as int8 "Q7" == -128 to 127. - * - * @param int8_t angle Q7 - * @return int8_t Q7 - */ -int8_t cos7(int8_t angle); - - - -#endif /* INC_MATH_SIN7_H_ */ diff --git a/src/gc9a01.c b/src/gc9a01.c deleted file mode 100644 index f1e93b7..0000000 --- a/src/gc9a01.c +++ /dev/null @@ -1,316 +0,0 @@ -#include "GC9A01.h" - -#define ORIENTATION 2 // Set the display orientation 0,1,2,3 - -// Command codes: -#define COL_ADDR_SET 0x2A -#define ROW_ADDR_SET 0x2B -#define MEM_WR 0x2C -#define COLOR_MODE 0x3A -#define COLOR_MODE__12_BIT 0x03 -#define COLOR_MODE__16_BIT 0x05 -#define COLOR_MODE__18_BIT 0x06 -#define MEM_WR_CONT 0x3C - -static void GC9A01_write_command(uint8_t cmd) { - GC9A01_set_data_command(0); - GC9A01_set_chip_select(0); - GC9A01_spi_tx(&cmd, sizeof(cmd)); - GC9A01_set_chip_select(1); -} - -static void GC9A01_write_data(uint8_t *data, size_t len) { - GC9A01_set_data_command(1); - GC9A01_set_chip_select(0); - GC9A01_spi_tx(data, len); - GC9A01_set_chip_select(1); -} - -static inline void GC9A01_write_byte(uint8_t val) { - GC9A01_write_data(&val, sizeof(val)); -} - -void GC9A01_init(void) { - - GC9A01_set_chip_select(1); - GC9A01_delay(5); - GC9A01_set_reset(0); - GC9A01_delay(10); - GC9A01_set_reset(1); - GC9A01_delay(120); - - /* Initial Sequence */ - - GC9A01_write_command(0xEF); - - GC9A01_write_command(0xEB); - GC9A01_write_byte(0x14); - - GC9A01_write_command(0xFE); - GC9A01_write_command(0xEF); - - GC9A01_write_command(0xEB); - GC9A01_write_byte(0x14); - - GC9A01_write_command(0x84); - GC9A01_write_byte(0x40); - - GC9A01_write_command(0x85); - GC9A01_write_byte(0xFF); - - GC9A01_write_command(0x86); - GC9A01_write_byte(0xFF); - - GC9A01_write_command(0x87); - GC9A01_write_byte(0xFF); - - GC9A01_write_command(0x88); - GC9A01_write_byte(0x0A); - - GC9A01_write_command(0x89); - GC9A01_write_byte(0x21); - - GC9A01_write_command(0x8A); - GC9A01_write_byte(0x00); - - GC9A01_write_command(0x8B); - GC9A01_write_byte(0x80); - - GC9A01_write_command(0x8C); - GC9A01_write_byte(0x01); - - GC9A01_write_command(0x8D); - GC9A01_write_byte(0x01); - - GC9A01_write_command(0x8E); - GC9A01_write_byte(0xFF); - - GC9A01_write_command(0x8F); - GC9A01_write_byte(0xFF); - - - GC9A01_write_command(0xB6); - GC9A01_write_byte(0x00); - GC9A01_write_byte(0x00); - - GC9A01_write_command(0x36); - -#if ORIENTATION == 0 - GC9A01_write_byte(0x18); -#elif ORIENTATION == 1 - GC9A01_write_byte(0x28); -#elif ORIENTATION == 2 - GC9A01_write_byte(0x48); -#else - GC9A01_write_byte(0x88); -#endif - - GC9A01_write_command(COLOR_MODE); - GC9A01_write_byte(COLOR_MODE__18_BIT); - - GC9A01_write_command(0x90); - GC9A01_write_byte(0x08); - GC9A01_write_byte(0x08); - GC9A01_write_byte(0x08); - GC9A01_write_byte(0x08); - - GC9A01_write_command(0xBD); - GC9A01_write_byte(0x06); - - GC9A01_write_command(0xBC); - GC9A01_write_byte(0x00); - - GC9A01_write_command(0xFF); - GC9A01_write_byte(0x60); - GC9A01_write_byte(0x01); - GC9A01_write_byte(0x04); - - GC9A01_write_command(0xC3); - GC9A01_write_byte(0x13); - GC9A01_write_command(0xC4); - GC9A01_write_byte(0x13); - - GC9A01_write_command(0xC9); - GC9A01_write_byte(0x22); - - GC9A01_write_command(0xBE); - GC9A01_write_byte(0x11); - - GC9A01_write_command(0xE1); - GC9A01_write_byte(0x10); - GC9A01_write_byte(0x0E); - - GC9A01_write_command(0xDF); - GC9A01_write_byte(0x21); - GC9A01_write_byte(0x0c); - GC9A01_write_byte(0x02); - - GC9A01_write_command(0xF0); - GC9A01_write_byte(0x45); - GC9A01_write_byte(0x09); - GC9A01_write_byte(0x08); - GC9A01_write_byte(0x08); - GC9A01_write_byte(0x26); - GC9A01_write_byte(0x2A); - - GC9A01_write_command(0xF1); - GC9A01_write_byte(0x43); - GC9A01_write_byte(0x70); - GC9A01_write_byte(0x72); - GC9A01_write_byte(0x36); - GC9A01_write_byte(0x37); - GC9A01_write_byte(0x6F); - - GC9A01_write_command(0xF2); - GC9A01_write_byte(0x45); - GC9A01_write_byte(0x09); - GC9A01_write_byte(0x08); - GC9A01_write_byte(0x08); - GC9A01_write_byte(0x26); - GC9A01_write_byte(0x2A); - - GC9A01_write_command(0xF3); - GC9A01_write_byte(0x43); - GC9A01_write_byte(0x70); - GC9A01_write_byte(0x72); - GC9A01_write_byte(0x36); - GC9A01_write_byte(0x37); - GC9A01_write_byte(0x6F); - - GC9A01_write_command(0xED); - GC9A01_write_byte(0x1B); - GC9A01_write_byte(0x0B); - - GC9A01_write_command(0xAE); - GC9A01_write_byte(0x77); - - GC9A01_write_command(0xCD); - GC9A01_write_byte(0x63); - - GC9A01_write_command(0x70); - GC9A01_write_byte(0x07); - GC9A01_write_byte(0x07); - GC9A01_write_byte(0x04); - GC9A01_write_byte(0x0E); - GC9A01_write_byte(0x0F); - GC9A01_write_byte(0x09); - GC9A01_write_byte(0x07); - GC9A01_write_byte(0x08); - GC9A01_write_byte(0x03); - - GC9A01_write_command(0xE8); - GC9A01_write_byte(0x34); - - GC9A01_write_command(0x62); - GC9A01_write_byte(0x18); - GC9A01_write_byte(0x0D); - GC9A01_write_byte(0x71); - GC9A01_write_byte(0xED); - GC9A01_write_byte(0x70); - GC9A01_write_byte(0x70); - GC9A01_write_byte(0x18); - GC9A01_write_byte(0x0F); - GC9A01_write_byte(0x71); - GC9A01_write_byte(0xEF); - GC9A01_write_byte(0x70); - GC9A01_write_byte(0x70); - - GC9A01_write_command(0x63); - GC9A01_write_byte(0x18); - GC9A01_write_byte(0x11); - GC9A01_write_byte(0x71); - GC9A01_write_byte(0xF1); - GC9A01_write_byte(0x70); - GC9A01_write_byte(0x70); - GC9A01_write_byte(0x18); - GC9A01_write_byte(0x13); - GC9A01_write_byte(0x71); - GC9A01_write_byte(0xF3); - GC9A01_write_byte(0x70); - GC9A01_write_byte(0x70); - - GC9A01_write_command(0x64); - GC9A01_write_byte(0x28); - GC9A01_write_byte(0x29); - GC9A01_write_byte(0xF1); - GC9A01_write_byte(0x01); - GC9A01_write_byte(0xF1); - GC9A01_write_byte(0x00); - GC9A01_write_byte(0x07); - - GC9A01_write_command(0x66); - GC9A01_write_byte(0x3C); - GC9A01_write_byte(0x00); - GC9A01_write_byte(0xCD); - GC9A01_write_byte(0x67); - GC9A01_write_byte(0x45); - GC9A01_write_byte(0x45); - GC9A01_write_byte(0x10); - GC9A01_write_byte(0x00); - GC9A01_write_byte(0x00); - GC9A01_write_byte(0x00); - - GC9A01_write_command(0x67); - GC9A01_write_byte(0x00); - GC9A01_write_byte(0x3C); - GC9A01_write_byte(0x00); - GC9A01_write_byte(0x00); - GC9A01_write_byte(0x00); - GC9A01_write_byte(0x01); - GC9A01_write_byte(0x54); - GC9A01_write_byte(0x10); - GC9A01_write_byte(0x32); - GC9A01_write_byte(0x98); - - GC9A01_write_command(0x74); - GC9A01_write_byte(0x10); - GC9A01_write_byte(0x85); - GC9A01_write_byte(0x80); - GC9A01_write_byte(0x00); - GC9A01_write_byte(0x00); - GC9A01_write_byte(0x4E); - GC9A01_write_byte(0x00); - - GC9A01_write_command(0x98); - GC9A01_write_byte(0x3e); - GC9A01_write_byte(0x07); - - GC9A01_write_command(0x35); - GC9A01_write_command(0x21); - - GC9A01_write_command(0x11); - GC9A01_delay(120); - GC9A01_write_command(0x29); - GC9A01_delay(20); - -} - -void GC9A01_set_frame(struct GC9A01_frame frame) { - - uint8_t data[4]; - - GC9A01_write_command(COL_ADDR_SET); - data[0] = (frame.start.X >> 8) & 0xFF; - data[1] = frame.start.X & 0xFF; - data[2] = (frame.end.X >> 8) & 0xFF; - data[3] = frame.end.X & 0xFF; - GC9A01_write_data(data, sizeof(data)); - - GC9A01_write_command(ROW_ADDR_SET); - data[0] = (frame.start.Y >> 8) & 0xFF; - data[1] = frame.start.Y & 0xFF; - data[2] = (frame.end.Y >> 8) & 0xFF; - data[3] = frame.end.Y & 0xFF; - GC9A01_write_data(data, sizeof(data)); - -} - -void GC9A01_write(uint8_t *data, size_t len) { - GC9A01_write_command(MEM_WR); - GC9A01_write_data(data, len); -} - -void GC9A01_write_continue(uint8_t *data, size_t len) { - GC9A01_write_command(MEM_WR_CONT); - GC9A01_write_data(data, len); -} \ No newline at end of file diff --git a/src/sin7.c b/src/sin7.c deleted file mode 100644 index d2a837a..0000000 --- a/src/sin7.c +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Example for a sine/cosine table lookup - * - * butchered by true to work in 7 bits (int8_t, two turns), and to fix cos8 function - * copied / inspired more or less from - * https://www.atwillys.de/content/cc/sine-lookup-for-embedded-in-c/ - **/ - -#include "sin7.h" - -/* - * The number of bits of our data type: here 8 (sizeof operator returns bytes). - */ -#define INT8_BITS (8 * sizeof(int8_t)) -#ifndef INT8_MAX -#define INT8_MAX ((1<<(INT8_BITS-1))-1) -#endif - -/* - * "5 bit" large table = 32 values. The mask: all bit belonging to the table - * are 1, the all above 0. - */ -#define TABLE_BITS (5) -#define TABLE_SIZE (1<> INTERP_BITS); - - if (v0 & FLIP_BIT) { - v0 = ~v0; - v1 = ~angle; - } else { - v1 = angle; - } - - v0 &= TABLE_MASK; - - v1 = sin90[v0] + (int8_t)(((int16_t)(sin90[v0+1]-sin90[v0]) * (v1 & INTERP_MASK)) >> INTERP_BITS); - - if((angle >> INTERP_BITS) & NEGATE_BIT) { - v1 = -v1; - } - - return v1; -} - -/** - * Cosine calculation using interpolated table lookup. - * Instead of radians or degrees we use "turns" here. Means this - * cosine does NOT return one phase for 0 to 2*PI, but for 0 to 1. - * Input: -1 to 1 as int8 == -128 to 127 - * Output: -1 to 1 as int8 == -128 to 127 - * - * @param int8_t angle - * @return int8_t - */ -int8_t cos7(int8_t angle) -{ - if (angle < 0) { - angle += INT8_MAX; - angle += 1; - } - - return sin7(angle - ((INT8_MAX * 3) / 4)); -}