Remove unneeded files

This commit is contained in:
true 2023-11-04 09:59:25 -07:00
parent c448ec8fa8
commit 03692bc44b
4 changed files with 0 additions and 503 deletions

View File

@ -1,36 +0,0 @@
#ifndef __GC9A01_H
#define __GC9A01_H
#include <stdint.h>
#include <stddef.h>
#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

View File

@ -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 <stdint.h>
/**
* 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_ */

View File

@ -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);
}

View File

@ -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<<TABLE_BITS)
#define TABLE_MASK (TABLE_SIZE-1)
/*
* The lookup table is to 90DEG, the input can be -360 to 360 DEG, where negative
* values are transformed to positive before further processing. We need two
* additional bits (*4) to represent 360 DEG:
*/
#define LOOKUP_BITS (TABLE_BITS+2)
#define LOOKUP_MASK ((1<<LOOKUP_BITS)-1)
#define FLIP_BIT (1<<TABLE_BITS)
#define NEGATE_BIT (1<<(TABLE_BITS+1))
#define INTERP_BITS (INT8_BITS-1-LOOKUP_BITS)
#define INTERP_MASK ((1<<INTERP_BITS)-1)
/**
* "5 bit" lookup table for the offsets. These are the sines for exactly
* at 0deg, 11.25deg, 22.5deg etc. The values are from -1 to 1 in Q8?.
*/
static const int8_t sin90[TABLE_SIZE + 1] = {
0x00, 0x06, 0x0c, 0x12, 0x18, 0x1e, 0x24, 0x2a,
0x30, 0x36, 0x3b, 0x41, 0x46, 0x4b, 0x50, 0x55,
0x59, 0x5e, 0x62, 0x66, 0x69, 0x6c, 0x70, 0x72,
0x75, 0x77, 0x79, 0x7b, 0x7c, 0x7d, 0x7e, 0x7e,
0x7f
};
/**
* 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 == -128 to 127
* Output: -1 to 1 as int8 == -128 to 127
*
* @param int8_t angle
* @return int8_t
*/
int8_t sin7(int8_t angle)
{
int8_t v0, v1;
if(angle < 0) {
angle += INT8_MAX;
angle += 1;
}
v0 = (angle >> 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));
}