Commit f604c357 authored by schneider's avatar schneider
Browse files

fix(ecg): Update example to new display

parent 61c4faab
......@@ -68,14 +68,19 @@ CMSIS_ROOT=$(LIBS_DIR)/CMSIS
# Source files for this test (add path to VPATH below)
SRCS = main.c
SRCS += pmic.c
SRCS += ../lib/card10/oled96.c
SRCS += ../lib/card10/fonts.c
SRCS += bosch.c
SRCS += bhy_support.c bhy_uc_driver.c bhy.c
SRCS += MAX77650-Arduino-Library.c
SRCS += bme680.h
SRCS += bma400.c
SRCS += LCD_Driver.c
SRCS += GUI_Paint.c
SRCS += DEV_Config.c
SRCS += font24.c
SRCS += font24CN.c
SRCS += card10.c
SRCS += display.c
# Where to find source files for this test
VPATH = .
......@@ -99,6 +104,16 @@ VPATH += ../lib/bosch/BME680_driver
IPATH += ../lib/bosch/BMA400-API
VPATH += ../lib/bosch/BMA400-API
IPATH += ../lib/gfx
IPATH += ../lib/gfx/LCD
IPATH += ../lib/gfx/GUI_DEV
IPATH += ../lib/gfx/Fonts
VPATH += ../lib/gfx
VPATH += ../lib/gfx/LCD
VPATH += ../lib/gfx/GUI_DEV
VPATH += ../lib/gfx/Fonts
# Enable assertion checking for development
PROJ_CFLAGS+=-DMXC_ASSERT_ENABLE
......
......@@ -53,7 +53,7 @@
#include "rtc.h"
#include "spi.h"
#include "MAX30003.h"
#include "oled96.h"
#include "GUI_DEV/GUI_Paint.h"
#include "pmic.h"
#include "card10.h"
#include <stdbool.h>
......@@ -166,34 +166,52 @@ void ecg_config(void)
return;
}
uint8_t content[1024];
#define SIZE_X 160
#define SIZE_Y 80
uint16_t content[SIZE_X*SIZE_Y];
uint8_t prev;
void clear(void)
{
memset(content, 0x00, 1024);
memset(content, 0x00, sizeof(content));
prev = 32;
}
void set(uint8_t index, int8_t val)
{
uint8_t *p = &content[index];
if(val < -31) val = -31;
if(val > 32) val = 32;
int8_t pos = -val + 32;
p += (pos / 8) * 128;
int8_t pos = val + 32;
int min, max;
if(prev < pos) {
min = prev;
max = pos;
} else {
min = pos;
max = prev;
}
for(int i = min; i < max + 1; i++) {
uint16_t *p = content;
p += i * SIZE_X + (SIZE_X - index - 1);
*p = 0x00F8;
}
*p |= (1 << (pos % 8));
prev = pos;
}
int16_t samples[256];
int16_t samples[SIZE_X*2];
void update(void)
{
clear();
int16_t scale = 0;
for(int i=0; i<256; i++) {
for(int i=0; i<SIZE_X*2; i++) {
if(abs(samples[i]) > scale) {
scale = abs(samples[i]);
}
......@@ -201,19 +219,19 @@ void update(void)
scale /= 32;
for(int i=0; i<128; i++) {
for(int i=0; i<SIZE_X; i++) {
set(i, ((samples[i*2] + samples[i*2 + 1]) / scale) / 2);
}
oledset(content);
LCD_Set((uint8_t*)content, sizeof(content));
}
uint8_t sample_count = 0;
void add_sample(int16_t sample)
{
memmove(samples, samples + 1, sizeof(*samples) * 255);
samples[255] = sample;
memmove(samples, samples + 1, sizeof(*samples) * (SIZE_X*2-1));
samples[SIZE_X*2-1] = sample;
sample_count++;
if(sample_count == 5) {
......
......@@ -22,7 +22,7 @@
#include <stdint.h>
#include <string.h>
#define SPI_SPEED 1000000 // Bit Rate
#define SPI_SPEED (15 * 1000 * 1000 * 1) // Bit Rate. Display has 15 MHz limit
void card10_init(void)
{
......
......@@ -38,14 +38,16 @@
//const gpio_cfg_t DEV_BL_PIN = {PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE};
/********************************************************************************/
void lcd_write(uint8_t data)
void lcd_write(uint8_t *data, int size)
{
spi_req_t req;
uint8_t tx_data[] = {data};
//uint8_t tx_data[] = {data};
uint8_t rx_data[] = {0};
req.tx_data = tx_data;
req.rx_data = rx_data;
req.len = 1;
//req.tx_data = tx_data;
req.tx_data = data;
//req.rx_data = rx_data;
req.rx_data = NULL;
req.len = size;
req.bits = 8;
req.width = SPI17Y_WIDTH_1;
req.ssel = 0;
......@@ -57,4 +59,3 @@ void lcd_write(uint8_t data)
SPI_MasterTrans(SPI, &req);
}
......@@ -60,9 +60,9 @@ extern const gpio_cfg_t DEV_DC_PIN;
/**
* SPI
**/
void lcd_write(uint8_t data);
void lcd_write(uint8_t* data, int size);
//#define DEV_SPI_WRITE(_dat) HAL_SPI_Transmit(&hspi1, (uint8_t *)&_dat, 1, 500);
#define DEV_SPI_WRITE(_dat) lcd_write(_dat)
#define DEV_SPI_WRITE(_dat) lcd_write(&_dat, 1)
/**
* delay x ms
......
......@@ -72,7 +72,8 @@ void LCD_WriteData_Byte(UBYTE da)
//DEV_Digital_Write(DEV_CS_PIN,0);
DEV_Digital_Write(DEV_DC_PIN,1);
DEV_SPI_WRITE(i);
DEV_SPI_WRITE(da);
uint8_t tmp = da;
DEV_SPI_WRITE(tmp);
//DEV_Digital_Write(DEV_CS_PIN,1);
}
......@@ -281,4 +282,9 @@ void LCD_SetUWORD(UWORD x, UWORD y, UWORD Color)
}
void LCD_Set(uint8_t *data, int len)
{
LCD_SetCursor(0,0,160-1,80-1);
DEV_Digital_Write(DEV_DC_PIN,1);
lcd_write(data, len);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment