Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: azonenberg/starshipraider
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6306f333bee0
Choose a base ref
...
head repository: azonenberg/starshipraider
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 23012afdbb23
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Jul 6, 2020

  1. Copy the full SHA
    e46a18a View commit details
  2. Copy the full SHA
    23012af View commit details
Showing with 107 additions and 36 deletions.
  1. +59 −21 firmware/MEAD/AMG240160P.cpp
  2. +11 −2 firmware/MEAD/AMG240160P.h
  3. +1 −1 firmware/MEAD/Makefile
  4. +35 −11 firmware/MEAD/main.cpp
  5. +1 −1 firmware/stm32-cpp
80 changes: 59 additions & 21 deletions firmware/MEAD/AMG240160P.cpp
Original file line number Diff line number Diff line change
@@ -46,8 +46,23 @@ static const CharacterCell8x16 g_bitmapFont8x16[256] __attribute__((section(".ro
{ 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, //08-0f
{ 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, //10-17
{ 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, //18-1f
{ 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, //20-27
{ 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, //28-2f

{ 0 }, //0x20 = ' '
{ 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00 }, //0x21 = '!'
{ 0x00, 0x00, 0x14, 0x14, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, //0x22 = '"'
{ 0x00, 0x00, 0x00, 0x24, 0x24, 0x7e, 0x24, 0x24, 0x24, 0x7e, 0x24, 0x24, 0x00, 0x00, 0x00, 0x00 }, //0x23 = '#'
{ 0x00, 0x08, 0x1c, 0x22, 0x22, 0x02, 0x1c, 0x20, 0x20, 0x22, 0x22, 0x1c, 0x08, 0x00, 0x00, 0x00 }, //0x24 = '$'
{ 0x00, 0x00, 0x02, 0x05, 0x45, 0x22, 0x10, 0x08, 0x04, 0x22, 0x51, 0x50, 0x20, 0x00, 0x00, 0x00 }, //0x25 = '%'
{ 0x00, 0x00, 0x0c, 0x12, 0x12, 0x12, 0x4c, 0x4a, 0x31, 0x21, 0x31, 0x4e, 0x00, 0x00, 0x00, 0x00 }, //0x26 = '&'
{ 0x00, 0x00, 0x10, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, //0x27 = '''
{ 0x00, 0x00, 0x10, 0x08, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x10, 0x00, 0x00, 0x00 }, //0x28 = '('
{ 0x00, 0x00, 0x04, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x04, 0x00, 0x00, 0x00 }, //0x29 = ')'
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x18, 0x7e, 0x18, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, //0x2a = '*'
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x3e, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, //0x2b = '+'
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x08, 0x00, 0x00, 0x00 }, //0x2c = ','
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, //0x2d = '-'
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00 }, //0x2e = '.'
{ 0x00, 0x00, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00 }, //0x2f = '/'

{ 0x00, 0x00, 0x3c, 0x42, 0x62, 0x52, 0x52, 0x4a, 0x4a, 0x46, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00 }, //0x30 = '0'
{ 0x00, 0x00, 0x20, 0x30, 0x28, 0x24, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00 }, //0x31 = '1'
@@ -140,6 +155,8 @@ AMG240160P::AMG240160P(SPI* spi, GPIOPin* csn, GPIOPin* rstn, GPIOPin* ctlData,
, m_rstn(rstn)
, m_ctlData(ctlData)
, m_usTimer(usTimer)
, m_writeX(0)
, m_writeY(0)
{
//Initialize pins
csn->Set(1);
@@ -179,25 +196,6 @@ AMG240160P::AMG240160P(SPI* spi, GPIOPin* csn, GPIOPin* rstn, GPIOPin* ctlData,

//Clear the screen
ClearScreen();

//Clear the framebuffer
for(int y=0; y<AMG240160P_FRAMEBUFFER_ROWS; y++)
{
for(int x=0; x<AMG240160P_FRAMEBUFFER_COLS; x++)
m_framebuffer[y][x] = ' ';
}

//Dummy text fill
strncpy(m_framebuffer[0], "ch0", AMG240160P_FRAMEBUFFER_COLS);
strncpy(m_framebuffer[2], "ch1", AMG240160P_FRAMEBUFFER_COLS);
strncpy(m_framebuffer[4], "ch2", AMG240160P_FRAMEBUFFER_COLS);
strncpy(m_framebuffer[6], "ch3", AMG240160P_FRAMEBUFFER_COLS);
strncpy(m_framebuffer[8], "ch4", AMG240160P_FRAMEBUFFER_COLS);
strncpy(m_framebuffer[10], "ch5", AMG240160P_FRAMEBUFFER_COLS);
strncpy(m_framebuffer[12], "ch6", AMG240160P_FRAMEBUFFER_COLS);
strncpy(m_framebuffer[14], "ch7", AMG240160P_FRAMEBUFFER_COLS);

UpdateScreen();
}

void AMG240160P::UpdateScreen()
@@ -303,4 +301,44 @@ void AMG240160P::ClearScreen()
SendData(0x00);
}
}

//Clear the framebuffer
for(int y=0; y<AMG240160P_FRAMEBUFFER_ROWS; y++)
{
for(int x=0; x<AMG240160P_FRAMEBUFFER_COLS; x++)
m_framebuffer[y][x] = ' ';
}
}

void AMG240160P::MoveTo(unsigned int x, unsigned int y)
{
m_writeX = x;
m_writeY = y;
}

void AMG240160P::PrintBinary(char ch)
{
//Bounds check coordinates
if( (m_writeX >= AMG240160P_FRAMEBUFFER_COLS) || (m_writeY >= AMG240160P_FRAMEBUFFER_ROWS) )
return;

//Carriage return / newline are special, don't actually write them
if(ch == '\n')
m_writeY ++;
else if(ch == '\r')
m_writeX = 0;

//Update the framebuffer
else
{
m_framebuffer[m_writeY][m_writeX] = ch;
m_writeX ++;
}

//Wrap at end of column
if(m_writeX >= AMG240160P_FRAMEBUFFER_COLS)
{
m_writeX = 0;
m_writeY ++;
}
}
13 changes: 11 additions & 2 deletions firmware/MEAD/AMG240160P.h
Original file line number Diff line number Diff line change
@@ -33,14 +33,15 @@
#include <peripheral/SPI.h>
#include <peripheral/GPIO.h>
#include <peripheral/Timer.h>
#include <util/CharacterDevice.h>

#define AMG240160P_FRAMEBUFFER_ROWS 16
#define AMG240160P_FRAMEBUFFER_COLS 20

/**
@brief Driver for an AMG240160P-W6WFDW LCD
*/
class AMG240160P
class AMG240160P : public CharacterDevice
{
public:
AMG240160P(SPI* spi, GPIOPin* csn, GPIOPin* rstn, GPIOPin* ctlData, Timer* usTimer);
@@ -50,9 +51,13 @@ class AMG240160P
void ClearScreen();
void UpdateScreen();

//The framebuffer
//Raw framebuffer access
char m_framebuffer[AMG240160P_FRAMEBUFFER_ROWS][AMG240160P_FRAMEBUFFER_COLS];

//Printing
void MoveTo(unsigned int x, unsigned int y);
virtual void PrintBinary(char ch);

protected:
bool GetPixel(unsigned int x, unsigned int y);

@@ -61,6 +66,10 @@ class AMG240160P
GPIOPin* m_rstn;
GPIOPin* m_ctlData;
Timer* m_usTimer;

//Current write position
unsigned int m_writeX;
unsigned int m_writeY;
};

#endif
2 changes: 1 addition & 1 deletion firmware/MEAD/Makefile
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ all:
$(CC) ../stm32-cpp/src/cpu/*.S -c $(CFLAGS)
$(CXX) ../stm32-cpp/src/newlib-stubs/*.cpp -c $(CXXFLAGS)
$(CXX) ../stm32-cpp/src/peripheral/*.cpp -c $(CXXFLAGS)
# $(CXX) ../stm32-cpp/src/util/*.cpp -c $(CXXFLAGS)
$(CXX) ../stm32-cpp/src/util/*.cpp -c $(CXXFLAGS)
$(CXX) ../stm32-cpp/devices/src/stm32f031.cpp -c $(CXXFLAGS)
$(CXX) $(CXXFLAGS) *.o -Wl,-T ../stm32-cpp/devices/link/stm32f031.ld -o firmware.elf
arm-none-eabi-objcopy -O binary --only-section=.text --only-section=.data firmware.elf firmware.bin
46 changes: 35 additions & 11 deletions firmware/MEAD/main.cpp
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
#include <peripheral/SPI.h>
#include <peripheral/I2C.h>
#include <peripheral/Timer.h>
#include <util/StringBuffer.h>
#include "AT30TS74.h"
#include "AMG240160P.h"

@@ -42,6 +43,8 @@
//UART stuff
UART* g_uart;

void UpdateSensors(AT30TS74* left, AT30TS74* right, AMG240160P* display);

//When possible, long-lived stuff here should be declared static.
//This puts them in .bss instead of stack, and enables better accounting of memory usage
int main()
@@ -91,19 +94,40 @@ int main()
static GPIOPin lcd_ctl_data(&GPIOA, 3, GPIOPin::MODE_OUTPUT);
AMG240160P lcd(&spi, &lcd_cs_n, &lcd_rst_n, &lcd_ctl_data, &timer);

/*
//Read the current temperatures
//Add initial channel names
for(int i=0; i<8; i++)
{
lcd.MoveTo(0, i*2);
lcd.Printf("CH%d", i);
}

//Read the current temperature
while(true)
{
//Refresh sensors and push to the display
UpdateSensors(&temp_left, &temp_right, &lcd);
lcd.UpdateScreen();

//Wait 500ms
for(int i=0; i<500; i++)
timer.Sleep(1000, true);
}

return 0;
}

void UpdateSensors(AT30TS74* left, AT30TS74* right, AMG240160P* display)
{
uint8_t temp;
uint8_t temp_frac;
temp_left.GetTemperature(temp, temp_frac);
g_uart->Printf("Left: %d.%02d C\n", temp, temp_frac * 100 / 256);
temp_right.GetTemperature(temp, temp_frac);
g_uart->Printf("Right: %d.%02d C\n", temp, temp_frac * 100 / 256);
*/

//Wait forever
while(1)
{}
//Left side
display->MoveTo(13, 1);
left->GetTemperature(temp, temp_frac);
display->Printf("%d.%02d C", temp, temp_frac * 100 / 256);

return 0;
//Right side
display->MoveTo(13, 13);
right->GetTemperature(temp, temp_frac);
display->Printf("%d.%02d C", temp, temp_frac * 100 / 256);
}