Skip to content
Permalink
Browse files

- renamed ST7735R to ST7735 as it support D and R versions

- added subprotocolname to commandline
- added menu to LCD library to choose which display is being probed
- minor UI tweaks
  • Loading branch information...
smdprutser committed Apr 19, 2018
1 parent 986c161 commit 400dccb3ce105f73db37580a8236b60409f45eae
Showing with 88 additions and 36 deletions.
  1. +1 −1 source/LA.c
  2. +32 −11 source/LCDSPI.c
  3. +8 −0 source/LCDSPI.h
  4. +1 −1 source/Makefile
  5. +25 −12 source/{ST7735R.c → ST7735.c}
  6. +5 −5 source/{ST7735R.h → ST7735.h}
  7. +7 −2 source/UI.c
  8. +5 −4 source/UI.h
  9. +4 −0 source/buspirateNG.h
@@ -232,7 +232,7 @@ void logicAnalyzerCaptureStop(void)
if(modeConfig.logicanalyzerstop<0xff){
modeConfig.logicanalyzersamplecount+=(timer_get_counter(BP_LA_COUNTER)+1);
}
cdcprintf("LA samples: %d\r\n", modeConfig.logicanalyzersamplecount);
//cdcprintf("LA samples: %d\r\n", modeConfig.logicanalyzersamplecount);

}

@@ -7,9 +7,10 @@
#include "cdcacm.h"
#include "UI.h"
#include "LCDSPI.h"
#include "protocols.h"

#include "HD44780.h"
#include "ST7735R.h"
#include "ST7735.h"

static uint32_t currentdisplay;

@@ -25,23 +26,25 @@ typedef struct _display
char name[10];
} display;

static struct _display displays[2]={
static struct _display displays[2]={ // HD44780 is mandatory
{
HD44780_write,
0, //HD44780_read,
nullfunc3, // read is not used
HD44780_macro,
HD44780_setup,
HD44780_cleanup,
"HD44780"
},
#ifdef DISPLAY_USE_ST7735
{
ST7735R_send,
0, //HD44780_read,
ST7735R_macro,
ST7735R_setup,
ST7735R_cleanup,
ST7735_send,
nullfunc3, // read is not used
ST7735_macro,
ST7735_setup,
ST7735_cleanup,
"ST7735D/R"
}
},
#endif
};

uint32_t LCDSPI_send(uint32_t d)
@@ -61,18 +64,36 @@ void LCDSPI_macro(uint32_t macro)

void LCDSPI_setup(void)
{

currentdisplay=1;
int i;

currentdisplay=0;
if(cmdtail!=cmdhead) cmdtail=(cmdtail+1)&(CMDBUFFSIZE-1);
consumewhitechars();
currentdisplay=getint();

if((currentdisplay==0)||(currentdisplay>MAXDISPLAYS))
{
for(i=0; i<MAXDISPLAYS; i++)
cdcprintf(" %2d. %s\r\n", i+1, displays[i].name);

currentdisplay=askint("\r\ndisplay> ", 1, 2, 1);
cdcprintf("\r\n");
}
currentdisplay--;
}

void LCDSPI_setup_exc(void)
{
displays[currentdisplay].display_setup();

modeConfig.subprotocolname=displays[currentdisplay].name;
}

void LCDSPI_cleanup(void)
{
displays[currentdisplay].display_cleanup();

modeConfig.subprotocolname=0;
}

void LCDSPI_pins(void)
@@ -8,3 +8,11 @@ void LCDSPI_cleanup(void);
void LCDSPI_pins(void);
void LCDSPI_settings(void);

enum
{
HD44780=0,
#ifdef DISPLAY_USE_ST7735
ST7735,
#endif
MAXDISPLAYS
};
@@ -23,7 +23,7 @@ CFLAGS +=-DFWVER=\"$(GIT_VERSION)\"

OBJS += debug.o cdcacm.o UI.o protocols.o dummy1.o dummy2.o HiZ.o HWSPI.o
OBJS += AUXpin.o ADC.o HWUSART.o bpflash.o HWI2C.o LA.o SW2W.o SW3W.o sump.o
OBJS += DIO.o LCDSPI.o HD44780.o ST7735R.o 1WIRE.o
OBJS += DIO.o LCDSPI.o HD44780.o ST7735.o 1WIRE.o

BINARY = buspirateNG

@@ -7,7 +7,7 @@
#include "cdcacm.h"
#include "UI.h"
#include "LCDSPI.h"
#include "ST7735R.h"
#include "ST7735.h"
#include "AUXpin.h"


@@ -164,21 +164,21 @@ static const uint8_t
100 }; // 100 ms delay


uint8_t maxx, maxy;



uint32_t ST7735R_send(uint32_t d)
uint32_t ST7735_send(uint32_t d)
{
ST7735_writedat(d);
return 0;
}

uint32_t ST7735R_read(void)
uint32_t ST7735_read(void)
{
return 0;
}

void ST7735R_macro(uint32_t macro)
void ST7735_macro(uint32_t macro)
{
uint32_t arg1;
uint32_t i;
@@ -187,34 +187,44 @@ void ST7735R_macro(uint32_t macro)
consumewhitechars();
arg1=getint();

cdcprintf("arg=%d", arg1);

switch(macro)
{
case 0: cdcprintf("\r\n");
cdcprintf(" 1. init ST7735B\r\n");
cdcprintf(" 2. init ST7735R 160x128 green tab\r\n");
cdcprintf(" 3. init ST7735R 160x128 red tab\r\n");
cdcprintf(" 4. init ST7735R 128x128\r\n");
cdcprintf(" 5. init ST7735R 160x80");
cdcprintf(" 5. init ST7735R 160x80\r\n");
cdcprintf(" 6. Clear screen\r\n");
cdcprintf(" 7. Send command\r\n");
break;
case 1: ST7735_sendinitseq(Bcmd);
maxx=160;
maxy=128;
break;
case 2: ST7735_sendinitseq(Rcmd1);
ST7735_sendinitseq(Rcmd2green);
ST7735_sendinitseq(Rcmd3);
maxx=160;
maxy=128;
break;
case 3: ST7735_sendinitseq(Rcmd1);
ST7735_sendinitseq(Rcmd2red);
ST7735_sendinitseq(Rcmd3);
maxx=160;
maxy=128;
break;
case 4: ST7735_sendinitseq(Rcmd1);
ST7735_sendinitseq(Rcmd2green144);
ST7735_sendinitseq(Rcmd3);
maxx=128;
maxy=128;
break;
case 5: ST7735_sendinitseq(Rcmd1);
ST7735_sendinitseq(Rcmd2green160x80);
ST7735_sendinitseq(Rcmd3);
maxx=160;
maxy=80;
break;
case 6: ST7735_writecmd(0x2A);
ST7735_writedat(0x00);
@@ -227,7 +237,7 @@ void ST7735R_macro(uint32_t macro)
ST7735_writedat(0x00);
ST7735_writedat(0x7F);
ST7735_writecmd(0x2c);
for(i=0; i<2*128*128; i++) ST7735_writedat(0x00);
for(i=0; i<2*maxx*maxy; i++) ST7735_writedat(0x00);
break;
case 7: ST7735_writecmd(arg1);

@@ -240,7 +250,7 @@ void ST7735R_macro(uint32_t macro)

}

void ST7735R_setup(void)
void ST7735_setup(void)
{
// setup SPI
HWSPI_setcpol(1<<1);
@@ -254,10 +264,13 @@ void ST7735R_setup(void)
setAUX(1);
HWSPI_setcs(1);

cdcprintf("Adafuit");
maxx=0;
maxy=0;

cdcprintf("code (C) Adafuit");
}

void ST7735R_cleanup(void)
void ST7735_cleanup(void)
{
HWSPI_cleanup();
}
@@ -1,10 +1,10 @@


void ST7735R_setup(void);
void ST7735R_cleanup(void);
uint32_t ST7735R_send(uint32_t d);
uint32_t ST7735R_read(void);
void ST7735R_macro(uint32_t macro);
void ST7735_setup(void);
void ST7735_cleanup(void);
uint32_t ST7735_send(uint32_t d);
uint32_t ST7735_read(void);
void ST7735_macro(uint32_t macro);
void ST7735_writedat(uint8_t d);
void ST7735_writecmd(uint8_t c);
void ST7735_sendinitseq(const uint8_t *addr );
@@ -176,6 +176,8 @@ void initUI(void)
modeConfig.cspin=0;
modeConfig.clkport=0;
modeConfig.clkpin=0;

modeConfig.subprotocolname=0;
}


@@ -568,10 +570,13 @@ void doUI(void)
logicAnalyzerCaptureStop();

if(modeConfig.logicanalyzerstop==0xff){
cdcprintf("Logic analyzer full before end of command!\r\n");
cdcprintf("\x07Logic analyzer full before end of command!\r\n");
}

cdcprintf("%s> ", protocols[modeConfig.mode].protocol_name);
if(modeConfig.subprotocolname)
cdcprintf("%s-(%s)> ", protocols[modeConfig.mode].protocol_name, modeConfig.subprotocolname);
else
cdcprintf("%s> ", protocols[modeConfig.mode].protocol_name);
if(go==2)
{
temp=0;
@@ -10,14 +10,15 @@ typedef struct _modeConfig
uint8_t bitorder; // bitorder (0=msb, 1=lsb)
uint8_t psu; // psu (0=off, 1=on)
uint8_t error; // error occurred
uint8_t displaymode; // display mode (dec, hex, oct, bin)
uint8_t displaymode; // display mode (dec, hex, oct, bin)
uint8_t pwm; // pwm active?
char *subprotocolname; // can be set if there is a sub protocol

uint8_t logicanalyzertriggersactive;
uint8_t logicanalyzertriggersdirection;
uint16_t logicanalyzerperiod; // period of the logic analyzer clock
uint32_t logicanalyzersamplecount; //number of samples in most recent capture
uint8_t logicanalyzerstop; //why did the logic analyzer stop?
uint16_t logicanalyzerperiod; // period of the logic analyzer clock
uint32_t logicanalyzersamplecount; //number of samples in most recent capture
uint8_t logicanalyzerstop; //why did the logic analyzer stop?

uint32_t csport; // cs is located on this port/gpio
uint32_t cspin;
@@ -26,6 +26,10 @@
//#define BP_USE_LCDI2C
#define BP_USE_1WIRE

// enable display support
#define DISPLAY_USE_HD44780 // is always enabled
#define DISPLAY_USE_ST7735


// systicks (for delays) systick is 10us
extern volatile uint32_t systicks;

0 comments on commit 400dccb

Please sign in to comment.
You can’t perform that action at this time.