Example project for the Rioux Chem control box
Rioux Chem Control Box
This is the example project for the Rioux Chem Control Box. I have posted some youtube videos to guide you through the hardware and software:
Rioux Chem Control Box - Hardware
http://www.youtube.com/watch?v=MoZ92GRYa4s
Rioux Chem Control Box - Software - Part I
http://www.youtube.com/watch?v=_MwaTLL4dyA==
Rioux Chem Control Box - Software - Part II
http://www.youtube.com/watch?v=j_P89izfgoQ
Revision 3:cb48919cd5e8, committed 2021-08-05
- Comitter:
- wavenumber
- Date:
- Thu Aug 05 02:12:29 2021 +0000
- Parent:
- 2:73a028278c5c
- Child:
- 4:e3eda81c97ae
- Commit message:
- Added BPIN and BPOUT commands to support the new back pressure regulator. Added red & green LED control objects. Removed all of the graphics functions for use on rev A
Changed in this revision
--- a/DRIVERS/CHEM_BOX_COMMON.cpp Mon Aug 31 13:00:37 2020 +0000
+++ b/DRIVERS/CHEM_BOX_COMMON.cpp Thu Aug 05 02:12:29 2021 +0000
@@ -20,6 +20,11 @@
DigitalOut AIO_DAC2_CS(p23);
+DigitalOut RED_LED(p20);
+
+DigitalOut GREEN_LED(p14);
+
+
DigitalOut MFC_POWER_CONTROL(p22);
PwmOut FAN_CONTROL(p21);
@@ -30,13 +35,11 @@
SPI SPI0(p11,p12,p13);
-DigitalOut SmartSwitch_SS(p14);
BusOut TEMP_SENSE_ADDRESS(p15,p16,p17,p18);
DigitalOut TEMP_SENSE_CS(p19);
-DigitalIn LCD_SWITCH(p20);
MODSERIAL RS232_0(p9, p10, 1024, 1024);
@@ -112,8 +115,6 @@
SPI0.frequency(4000000);
- SmartSwitch_SS = 1;
-
TEMP_SENSE_ADDRESS = 0;
TEMP_SENSE_CS = 1;
@@ -133,8 +134,7 @@
Thermocouple_OC= 0;
InitTerminal();
-
- GFX_Init();
+
}
@@ -356,6 +356,8 @@
}
+
+
float Read4to20(uint8_t Channel)
{
@@ -367,7 +369,17 @@
}
-static uint16_t ReadRawADC(uint8_t Channel)
+float ReadBP_AnalogInput()
+{
+
+ return ((float)(ReadRawADC(15)) /4095.0) * 10.0;
+
+}
+
+
+
+
+static uint16_t ReadRawADC_Single(uint8_t Channel)
{
uint8_t ControlByte[3];
uint8_t ADC_Data[3];
@@ -402,6 +414,22 @@
}
+#define FILTER_SIZE 64
+
+static uint16_t ReadRawADC(uint8_t Channel)
+{
+ uint32_t Value = 0;
+
+ for(int i=0;i<FILTER_SIZE;i++)
+ {
+ Value+=ReadRawADC_Single(Channel);
+ }
+
+ Value = Value / FILTER_SIZE;
+
+ return Value;
+
+}
void WriteMFC_AnalogOut(uint8_t Channel,float Value)
{
@@ -433,6 +461,18 @@
WriteRAW_DAC_Value(8+Channel,(uint16_t)((Value/5.0)*4095));
}
+void WriteBP_AnalogOut(float Value)
+{
+
+ if(Value >10.0)
+ Value = 10.0;
+
+ if(Value<0.0)
+ Value = 0.0;
+
+ WriteRAW_DAC_Value(12,(uint16_t)((Value/10.0)*4095));
+}
+
void WriteRAW_DAC_Value(uint8_t Channel,uint16_t Data)
{
@@ -442,7 +482,10 @@
if(Channel<8)
AIO_DAC1_CS = 0;
else
+ {
AIO_DAC2_CS = 0;
+ Channel -= 8;
+ }
SPI0.format(8,1); //The DAC requires mode 0,1
@@ -505,6 +548,8 @@
void TerminalCmd_AOUT(char *arg);
void TerminalCmd_Reset(char *arg);
void TerminalCmd_ECHO_OFF(char *arg);
+void TerminalCmd_BPOUT(char *arg);
+void TerminalCmd_BPIN(char *arg);
//Populate this array with the callback functions and their terminal command string
TerminalCallbackRecord MyTerminalCallbackRecords[] ={ {"reset",TerminalCmd_Reset,"Resets the CHEM box"},
@@ -549,6 +594,11 @@
{"MFCOFF",TerminalCmd_MFCOFF,"Turns off the MFC power"},
+ {"BPOUT",TerminalCmd_BPOUT,"Sets a control voltage between 0 and 10 for the backpressure regulator. I.E. BPOUT 1.21"},
+
+ {"BPIN",TerminalCmd_BPIN,"Reads the Back pressure regulator feedback. I.E. BPIN "},
+
+
{"ECHO_OFF",TerminalCmd_ECHO_OFF,"Disables echoing of characters"}
};
@@ -655,6 +705,28 @@
}
}
+
+void TerminalCmd_BPOUT(char *arg)
+{
+ float Data = 0.0;
+
+ if(sscanf(arg,"%f",&Data) == 1)
+ {
+ WriteBP_AnalogOut(Data);
+ }
+ else
+ {
+ PC.printf("Bad argument... %s. value should be a float between 0.0 and 10.0. i.e. BPOUT 1.25",arg);
+ }
+}
+
+void TerminalCmd_BPIN(char *arg)
+{
+ float Data;
+ Data = ReadBP_AnalogInput();
+ PC.printf("BPIN:%.3f",Data);
+}
+
void TerminalCmd_4TO20(char *arg)
{
int Channel = -1;
@@ -900,14 +972,14 @@
if(sscanf(arg,"%d",&Channel) == 1)
{
Temp = ReadThermocouple(Channel);
- PC.printf("TEMP:%d:%.2f\r\n",Channel,Temp);
+ PC.printf("TEMP:%d:%.2f:%d\r\n",Channel,Temp,Thermocouple_OC);
}
else
{
for(Channel = 0; Channel<12;Channel++)
{
Temp = ReadThermocouple(Channel);
- PC.printf("TEMP:%d:%.2f\r\n",Channel,Temp);
+ PC.printf("TEMP:%d:%.2f:%d\r\n",Channel,Temp,Thermocouple_OC);
}
}
}
@@ -1126,729 +1198,3 @@
-
-// _ _____ _____ _______ _____ _____ _ _ _____ _____ _____
-// | | / ____| __ \ / / ____| __ \ /\ | __ \| | | |_ _/ ____|/ ____|
-// | | | | | | | | / / | __| |__) | / \ | |__) | |__| | | || | | (___
-// | | | | | | | |/ /| | |_ | _ / / /\ \ | ___/| __ | | || | \___ \
-// | |___| |____| |__| / / | |__| | | \ \ / ____ \| | | | | |_| || |____ ____) |
-// |______\_____|_____/_/ \_____|_| \_\/_/ \_\_| |_| |_|_____\_____|_____/
-//
-//
-
-void SmartSwitch_Reset();
-void SmartSwitch_SetBrightness(uint8_t Brightness);
-void InitSmartSwitch();
-void PowerUpSmartSwitch();
-void PowerDownSmartSwitch();
-void SmartSwitchWriteByte(uint8_t DataOut);
-void SmartSwitch_SetBackLightColor2(uint8_t RGB);
-void SmartSwitch_ImageDump(uint8_t *Img);
-void SmartSwitchClear();
-
-
-
-
-#define BACK_BUFFER_SIZE_X (64)
-#define BACK_BUFFER_SIZE_Y (32)
-
-#define PHYSICAL_DISPLAY_XRES (uint8_t)(64)
-#define PHYSICAL_DISPLAY_YRES (uint8_t)(32)
-#define DISPLAY_X_WIDTH_BYTE (PHYSICAL_DISPLAY_XRES>>3)
-#define DISPLAY_BUFFER_TOTAL_SIZE (DISPLAY_X_WIDTH_BYTE*PHYSICAL_DISPLAY_YRES*2)
-#define GREEN_DATA_BUFFER_OFFSET (DISPLAY_X_WIDTH_BYTE * PHYSICAL_DISPLAY_YRES)
-#define PHYSICAL_DISPLAY_X_WIDTH_IN_BYTES (PHYSICAL_DISPLAY_XRES>>3)
-#define PHYSICAL_DISPLAY_PLANE_BUFFER_SIZE (PHYSICAL_DISPLAY_X_WIDTH_IN_BYTES * PHYSICAL_DISPLAY_YRES)
-#define PHYSICAL_DISPLAY_BUFFER_TOTAL_SIZE (PHYSICAL_DISPLAY_X_WIDTH_IN_BYTES * PHYSICAL_DISPLAY_YRES*2)
-
-#define SMART_SWITCH_CMD_DISPLAY_DATA 0x55
-#define SMART_SWITCH_CMD_SET_BACKLIGHT_COLOR 0x40
-#define SMART_SWITCH_CMD_SET_BRIGHTNESS 0x41
-#define SMART_SWITCH_CMD_RESET 0x5E
-#define SMART_SWITCH_CMD_RESET_PARAMETER 0x03
-
-#define SMART_SWITCH_BACKLIGHT_RED (0x03<<4)
-#define SMART_SWITCH_BACKLIGHT_YELLOW (0x03<<4)|(0x03<<2)
-#define SMART_SWITCH_BACKLIGHT_GREEN (0x03<<2)
-
- #define GFX_MAX_STRING_LEN 32
-
-void SmartSwitch_ImageDump(uint8_t *Img)
-{
- int i;
-
- SPI1.format(8,2);
-
- SmartSwitch_SS = 0;
- SmartSwitchWriteByte(SMART_SWITCH_CMD_DISPLAY_DATA);
-
- for(i=0;i<256;i++)
- {
- SmartSwitchWriteByte(Img[i]);
- }
-
- SmartSwitch_SS = 1;
-}
-
-void SmartSwitchClear()
-{
- int i;
-
-
- SPI1.format(8,2);
-
- SmartSwitch_SS = 0;
- SmartSwitchWriteByte(SMART_SWITCH_CMD_DISPLAY_DATA);
-
- for(i=0;i<256;i++)
- {
- SmartSwitchWriteByte(0x00);
- }
-
- SmartSwitch_SS = 1;
-}
-
-void SmartSwitch_Reset()
-{
-
- SPI1.format(8,2);
-
- SmartSwitch_SS = 0;
- SmartSwitchWriteByte(SMART_SWITCH_CMD_RESET);
- SmartSwitchWriteByte(SMART_SWITCH_CMD_RESET_PARAMETER);
- SmartSwitch_SS = 1;
-}
-
-void SmartSwitch_SetBackLightColor(uint8_t Red,uint8_t Green,uint8_t Blue)
-{
-
- SPI1.format(8,2);
-
- SmartSwitch_SS = 0;
- SmartSwitchWriteByte(SMART_SWITCH_CMD_SET_BACKLIGHT_COLOR);
- SmartSwitchWriteByte(Red<<6 | Green<<4 | Blue <<2 | 0x3);
- SmartSwitch_SS = 1;
-}
-
-void SmartSwitch_SetBackLightColor2(uint8_t RGB)
-{
- SPI1.format(8,2);
-
- SmartSwitch_SS = 0;
- SmartSwitchWriteByte(SMART_SWITCH_CMD_SET_BACKLIGHT_COLOR);
- SmartSwitchWriteByte(RGB<<2 | 0x3);
- SmartSwitch_SS = 1;
-}
-
-void SmartSwitch_SetBrightness(uint8_t Brightness)
-{
- SPI1.format(8,2);
-
- SmartSwitch_SS = 0;
- SmartSwitchWriteByte(SMART_SWITCH_CMD_SET_BRIGHTNESS);
- SmartSwitchWriteByte(Brightness<<5 | 0x1F);
- SmartSwitch_SS = 1;
-}
-
-void InitSmartSwitch()
-{
- SmartSwitch_SS = 1;
- SmartSwitch_Reset();
-}
-
-void SmartSwitchWriteByte(uint8_t DataOut)
-{
-
- SPI1.write(DataOut);
-
-}
-
-
-//Linking Functions to Physical Screen
-//***********************************************************************************
-
-void GFX_InitPhysicalScreen()
-{
- InitSmartSwitch();
-}
-
-
-const uint8_t BitReverseTable[256] =
-{
-0x00, 0x80, 0x40, 0xc0, 0x20, 0x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 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
-0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
-0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
-0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
-0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
-0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
-0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
-0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
-0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
-};
-
-void GFX_DumpRenderContextToPhysicalScreen(RenderContext *Image)
-{
- int x,y;
- uint8_t NextByteOut;
-
- SPI1.format(8,2);
-
- SmartSwitch_SS = 0;
- SmartSwitchWriteByte(SMART_SWITCH_CMD_DISPLAY_DATA);
-
- for(y=0;y<PHYSICAL_DISPLAY_YRES;y++)
- {
- for(x=0;x<PHYSICAL_DISPLAY_X_WIDTH_IN_BYTES;x++)
- {
- //Need to rotate the display 180 degrees
- NextByteOut = Image->RenderPlane.BitPlaneSpace[(((PHYSICAL_DISPLAY_YRES - y - 1) * PHYSICAL_DISPLAY_X_WIDTH_IN_BYTES)) + x];
- SmartSwitchWriteByte(BitReverseTable[NextByteOut]);
- }
- }
- SmartSwitch_SS = 1;
-}
-
-
-//Device Independent Functions
-//***********************************************************************************
-
-//Reserve Space for the backbuffer
-
-RenderContext BackBuffer;
-uint8_t BackBufferRenderPlaneSpace[PHYSICAL_DISPLAY_PLANE_BUFFER_SIZE];
-
-int16_t GFX_Drawcharacter(RenderContext *Image, uint8_t character, int16_t StartX, int16_t StartY, GFXFont *MyFont);
-int16_t GFX_GetStringWidth(char * String,GFXFont * MyFont);
-
-//FontData
-
-#define FONT5x7_FONT_WIDTH 5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Font Font3x5;
-
-void GFX_Init()
-{
-
- //Staticially Allocate and setup the backbuffer space;
-
- BackBuffer.RenderPlane.BitPlaneSpace = &BackBufferRenderPlaneSpace[0];
-
- BackBuffer.SizeX = BACK_BUFFER_SIZE_X;
- BackBuffer.SizeY = BACK_BUFFER_SIZE_Y;
-
- BackBuffer.RenderPlane.SizeX = BACK_BUFFER_SIZE_X;
- BackBuffer.RenderPlane.SizeY = BACK_BUFFER_SIZE_Y;
-
-
- GFX_FullDisplayBufferClear(&BackBuffer);
-
- //Initialize the stock fonts
-
- Font5x7.CharacterWidthTable = (uint8_t *)CharacterWidthTable_Font5x7;
- Font5x7.FontBuffer = (uint8_t *)FontTable_Font5x7;
- Font5x7.FontHeight = FONT5x7_FONT_HEIGHT;
- Font5x7.FontWidth = FONT5x7_FONT_WIDTH;
- Font5x7.BytesPerColumn = FONT5x7_FONT_COLUMN_SIZE_IN_BYTE;
-
- Font3x5.CharacterWidthTable = (uint8_t *)CharacterWidthTable_Font3x5;
- Font3x5.FontBuffer = (uint8_t *)FontTable_Font3x5;
- Font3x5.FontHeight = FONT3x5_FONT_HEIGHT;
- Font3x5.FontWidth = FONT3x5_FONT_WIDTH;
- Font3x5.BytesPerColumn = FONT3x5_FONT_COLUMN_SIZE_IN_BYTE;
-
- GFX_InitPhysicalScreen();
-
-}
-
-
-
-void GFX_FullDisplayBufferClear(RenderContext *Image)
-{
- BitPlane_Clear(&Image->RenderPlane);
-}
-
-
-void GFX_PutPixel(RenderContext *Image, int16_t x, int16_t y)
-{
- if((x<Image->SizeX) && (y<Image->SizeY) && (x>=0) && (y>=0))
- {
- BitPlane_Put(&Image->RenderPlane,Image->SizeX-x-1,Image->SizeY-y-1,TRUE);
- }
-}
-
-
-
-#ifndef _INLINE_GFX_GET_PIXEL
-uint8_t GFX_GetPixel(RenderContext *Image, int16_t x, int16_t y)
-{
- uint8_t PixelColor = 0;
-
- if((x<Image->SizeX) && (y<Image->SizeY) && (x>=0) && (y>=0))
- {
-
- PixelColor = BitPlane_Get(&Image->RenderPlane,x,y);
- }
-
- return PixelColor;
-}
-#endif
-
-
-void GFX_DrawHline(RenderContext *Image, int16_t XStart, int16_t XStop, int16_t Y)
-{
- int16_t LineStart;
- int16_t LineStop;
- uint16_t i;
-
- if((Y<Image->SizeY) && (Y>=0))
- {
- if(XStart>XStop)
- {
- LineStart = XStop;
- LineStop = XStart;
- }
- else
- {
- LineStart = XStart;
- LineStop = XStop;
- }
-
- if(LineStart<0)
- {
- LineStart = 0;
- }
-
- if(LineStop>Image->SizeX)
- {
- LineStop = Image->SizeX-1;
- }
-
- if(LineStart == LineStop)
- {
- GFX_PutPixel(Image,LineStart,Y);
- }
- else
- {
- for(i=LineStart; i<=LineStop ; i++)
- {
- GFX_PutPixel(Image,i,Y);
- }
- }
- }
-
-}
-
-
-
- void GFX_DrawVline(RenderContext *Image, int16_t YStart, int16_t YStop, int16_t X)
-{
- int16_t LineStart;
- int16_t LineStop;
- int16_t i;
-
- if((X<Image->SizeX) && (X>=0))
- {
-
- if(YStart>YStop)
- {
- LineStart = YStop;
- LineStop = YStart;
- }
- else
- {
- LineStart = YStart;
- LineStop = YStop;
- }
-
- if(LineStart<0)
- {
- LineStart = 0;
- }
-
-
- if(LineStop>Image->SizeY)
- {
- LineStop = Image->SizeY-1;
- }
-
- for(i=LineStart; i<=LineStop ; i++)
- {
- GFX_PutPixel(Image,X,i);
- }
- }
-}
-
-
-void GFX_DrawLine(RenderContext * Image, int16_t X1,int16_t Y1, int16_t X2,int16_t Y2)
-{
- //A simple Implementation of Bresenham's line Algorithm
- int16_t StartX,StopX,StartY,StopY;
- int16_t dX,dY;
- int16_t Y_Numerator;
- int16_t X_Numerator;
- int16_t Y;
- int16_t X;
- int16_t i;
- uint8_t YDir = 0;
- //First Make sure that it is left to right
- //If not them flop them
- if(X2>X1)
- {
- StartX = X1;
- StopX = X2;
- StartY = Y1;
- StopY = Y2;
- }
- else
- {
- StartX = X2;
- StopX = X1;
- StartY = Y2;
- StopY = Y1;
- }
- GFX_PutPixel(Image, StopX,StopY);
- if(StopY>=StartY)
- {
- dY = StopY - StartY;
- YDir = 0;
- }
- else
- {
- dY = StartY - StopY;
- YDir = 1;
- }
- dX = StopX - StartX;
- //Now, if the slope is less greater than one, we need to swap all X/Y operations
- if(dY<=dX)
- {
- //Slope is less than one, proceed at normal and step along the x axis
- Y=StartY; //start the whole part of the Y value at the starting pixeel.
- X=StartX;
- //We need to start the numerator of the fraction half way through the fraction so evertyhing rounds at
- //fraction midpoint
- Y_Numerator = dX>>1; //The fraction demonimator is assumeed to be dX
- // out fixed point Y value is Y + (Y_Numerator / dX)
- //Every time we step the X coordinate by one, we need to step
- //out Y coordinate by dY/dX. We do this by just adding dY to our
- //numerator. When the numerator gets bigger than the
- //denomiator, the increment the whole part by one and decrement the numerator
- //by the denominator
- for(i=0;i<dX;i++)
- {
- GFX_PutPixel(Image,X,Y);
- X++;
- //Now do all the fractional stuff
- Y_Numerator += dY;
- if(Y_Numerator >= dX)
- {
- Y_Numerator-=dX;
- if(StopY > StartY)
- {
- Y++;
- }
- else
- {
- Y--;
- }
- }
- }
- }
- else
- {
- //Same as before by step along the y axis.
- Y=StartY;
- X=StartX;
- X_Numerator = dY>>1;
- for(i=0;i<dY;i++)
- {
- GFX_PutPixel(Image,X,Y);
- //Now do all the fractional stuff
- if(YDir)
- {
- Y--;
- }
- else
- {
- Y++;
- }
- X_Numerator += dX;
- if(X_Numerator >= dY)
- {
- X_Numerator-=dY;
- if(StopX > StartX)
- {
- X++;
- }
- else
- {
- X--;
- }
- }
- }
- }
-}
-
-void GFX_DrawBox(RenderContext *Image, GFXDisplayBox *Box)
-{
- GFX_DrawHline(Image,Box->P1.X,Box->P2.X,Box->P1.Y);
- GFX_DrawHline(Image,Box->P1.X,Box->P2.X,Box->P2.Y);
- GFX_DrawVline(Image,Box->P1.Y,Box->P2.Y,Box->P1.X);
- GFX_DrawVline(Image,Box->P1.Y,Box->P2.Y,Box->P2.X);
-}
-
-int16_t GFX_DrawCharacter(RenderContext * Image,uint8_t Character,int16_t StartX, int16_t StartY, GFXFont * MyFont)
-{
- uint8_t i,j,Mask;
- uint16_t CharStartIndex,ColumnStartIndex,ByteOffset;
-
- CharStartIndex = (Character * (MyFont->BytesPerColumn) * (MyFont->FontWidth));
-
- for(j=0;j<MyFont->CharacterWidthTable[Character];j++)
- {
- //Draw the current slice
- ColumnStartIndex = j* (MyFont->BytesPerColumn);
-
- for(i=0;i<MyFont->FontHeight;i++)
- {
- ByteOffset = i>>3;
- Mask = 0x01 << (i&0x07);
-
- if( (MyFont->FontBuffer[CharStartIndex + ColumnStartIndex + ByteOffset]) & Mask)
- {
- GFX_PutPixel(Image, StartX, StartY + i);
- }
- }
- StartX++;
- }
- return StartX;
-}
-
-
-int16_t GFX_GetStringWidth(char * String,GFXFont * MyFont)
-{
- uint8_t Ptr = 0;
- uint8_t NextChar;
- int16_t StringSize = 0;
-
- NextChar = String[Ptr];
- Ptr++;
-
- while((NextChar!=0) && (Ptr <GFX_MAX_STRING_LEN))
- {
- StringSize += MyFont->CharacterWidthTable[NextChar] + 1;
- NextChar = String[Ptr];
- Ptr++;
- }
-
- return StringSize;
-}
-
-void GFX_DrawCenteredString(RenderContext * Image,char * String,int16_t StartX, int16_t StartY, GFXFont * MyFont)
-{
- StartX -= (GFX_GetStringWidth(String,MyFont)>>1);
- GFX_DrawString(Image,String,StartX,StartY,MyFont);
-}
-
-void GFX_DrawString(RenderContext * Image,char * String,int16_t StartX, int16_t StartY, GFXFont * MyFont)
-{
-
-uint8_t Ptr = 0;
-uint8_t NextChar;
-
-NextChar = String[Ptr];
-
- while((NextChar!=0) && (Ptr <GFX_MAX_STRING_LEN))
- {
- StartX = GFX_DrawCharacter(Image,NextChar,StartX,StartY,MyFont);
- Ptr++;
- NextChar = String[Ptr];
- StartX++;
- }
-
-}
-
-char GFXStringBuf[64];
-
-void GFX_printf(RenderContext * Image,int16_t StartX, int16_t StartY, GFXFont * MyFont, const char *FormatString,...)
-{
- va_list argptr;
- va_start(argptr,FormatString);
- vsprintf((char *)GFXStringBuf,FormatString,argptr);
- va_end(argptr);
-
- GFX_DrawString(Image,GFXStringBuf,StartX,StartY,MyFont);
-}
-
-#ifndef INLINE_BITPLANE_PUT
-void BitPlane_Put(BitPlane * BP, uint16_t X,uint16_t Y, uint8_t Value)
-{
- uint16_t Offset;
- uint8_t Mask;
-
- Offset = (Y * ((BP->SizeX)>>3)) + (X>>3);
- Mask = 0x01 << (X & 0x07);
-
- if(Value)
- {
- BP->BitPlaneSpace[Offset] |= Mask;
- }
- else
- {
- BP->BitPlaneSpace[Offset] &= ~Mask;
- }
-}
-#endif
-
-#ifndef INLINE_BITPLANE_GET
-uint8_t BitPlane_Get(BitPlane * BP, uint16_t X,uint16_t Y)
-{
- uint16_t Offset;
- uint8_t Mask;
-
- Offset = (Y * ((BP->SizeX)>>3)) + (X>>3);
- Mask = 0x01 << (X & 0x07);
-
- if((BP->BitPlaneSpace[Offset])&Mask)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
-}
-#endif
-
-void BitPlane_Clear(BitPlane * BP)
-{
- uint16_t PlaneSpaceSize;
- uint16_t i;
-
- PlaneSpaceSize = ((BP->SizeX)>>3) * BP->SizeY;
-
- for (i=0;i<PlaneSpaceSize;i++) {
- BP->BitPlaneSpace[i] = 0;
- }
-}
--- a/DRIVERS/CHEM_BOX_INTERFACE.h Mon Aug 31 13:00:37 2020 +0000
+++ b/DRIVERS/CHEM_BOX_INTERFACE.h Thu Aug 05 02:12:29 2021 +0000
@@ -3,7 +3,7 @@
#ifndef CHEM_BOX_INTERFACE
#define CHEM_BOX_INTERFACE
-#define API_VERSION "1.0"
+#define API_VERSION "1.1"
// _____ _ _ ______ __ __ ____ ______ __ _____ _____
// / ____| | | | ____| \/ | | _ \ / __ \ \ / / /\ | __ \_ _|
@@ -17,6 +17,10 @@
//Initializes the hardware for the Chem box. Must be called before any other CHEM box functions are called.
void InitChemBox();
+extern DigitalOut RED_LED;
+
+extern DigitalOut GREEN_LED;
+
//Special Note.... All of the Digital IO functions are queued. This means that they do not take effect
//until the function FlushDigitalIO() is called.
@@ -159,165 +163,4 @@
extern MODSERIAL PC;
-// _____ _ _ _____ _____
-// / ____| | | (_) /\ | __ \_ _|
-// | | __ _ __ __ _ _ __ | |__ _ ___ ___ / \ | |__) || |
-// | | |_ | '__/ _` | '_ \| '_ \| |/ __/ __| / /\ \ | ___/ | |
-// | |__| | | | (_| | |_) | | | | | (__\__ \ / ____ \| | _| |_
-// \_____|_| \__,_| .__/|_| |_|_|\___|___/ /_/ \_\_| |_____|
-// | |
-// |_|
-
-#define PHYSICAL_DISPLAY_XRES (uint8_t)(64)
-#define PHYSICAL_DISPLAY_YRES (uint8_t)(32)
-
-#define _INLINE_GFX_GET_PIXEL
-#define _INLINE_GFX_PUT_PIXEL
-
-typedef struct
-{
- uint8_t *BitPlaneSpace;
- uint16_t SizeX; // must be a uint8_t aligned
- uint16_t SizeY;
-
-} BitPlane;
-
-
-typedef struct
-{
- int16_t X;
- int16_t Y;
-} GFXDisplayPoint;
-
-
-typedef struct
-{
- BitPlane RenderPlane;
- uint16_t SizeX;
- uint16_t SizeY;
-
-} RenderContext;
-
-
-typedef struct
-{
- GFXDisplayPoint P1;
- GFXDisplayPoint P2;
-} GFXDisplayBox;
-
-
-typedef struct
-{
- uint8_t FontWidth;
- uint8_t FontHeight;
- uint8_t BytesPerColumn;
- uint8_t *FontBuffer;
- uint8_t *CharacterWidthTable;
-
-} GFXFont;
-
-
-//System/Hardware specific stuff
-void GFX_InitPhysicalScreen();
-void GFX_DumpRenderContextToPhysicalScreen(RenderContext *Image);
-void GFX_Init();
-void GFX_PowerUpScreen();
-void GFX_PowerDownScreen();
-
-//Useful User Graphics Functions
-void GFX_FullDisplayBufferClear(RenderContext *Image);
-//Draws a single pixel
-void GFX_PutPixel(RenderContext *Image, int16_t x, int16_t y);
-//draws a horizontal line
-void GFX_DrawHline(RenderContext *Image, int16_t XStart, int16_t XStop, int16_t Y);
-//Draws a veritcal line
-void GFX_DrawVline(RenderContext *Image, int16_t YStart, int16_t YStop, int16_t X);
-//Draws a line between 2 points
-void GFX_DrawLine(RenderContext *Image, int16_t X1,int16_t Y1, int16_t X2,int16_t Y2);
-//Draws a box
-void GFX_DrawBox(RenderContext *Image, GFXDisplayBox *Box);
-//Draws a string
-void GFX_DrawString(RenderContext * Image,char * String,int16_t StartX, int16_t StartY, GFXFont * MyFont);
-//Draws a string using standard printf escape sequences
-void GFX_printf(RenderContext * Image,int16_t StartX, int16_t StartY, GFXFont * MyFont, const char *FormatString,...);
-//Draws a string that is horizontally centered
-void GFX_DrawCenteredString(RenderContext * Image,char * String,int16_t StartX, int16_t StartY, GFXFont * MyFont);
-
-
-
-#ifdef INLINE_BITPLANE_PUT
- inline void BitPlane_Put(BitPlane * BP, uint16_t X,uint16_t Y, uint8_t Value)
- {
- uint16_t Offset;
- uint8_t Mask;
-
- Offset = (Y * ((BP->SizeX)>>3)) + (X>>3);
- Mask = 0x01 << (X & 0x07);
-
- if(Value)
- {
- BP->BitPlaneSpace[Offset] |= Mask;
- }
- else
- {
- BP->BitPlaneSpace[Offset] &= ~Mask;
- }
- }
-#else
- void BitPlane_Put(BitPlane * BP, uint16_t X,uint16_t Y, uint8_t Value);
-#endif
-
-#ifdef INLINE_BITPLANE_GET
- inline uint8_t BitPlane_Get(BitPlane * BP, uint16_t X,uint16_t Y)
- {
- uint16_t Offset;
- uint8_t Mask;
-
- Offset = (Y * ((BP->SizeX)>>3)) + (X>>3);
- Mask = 0x01 << (X & 0x07);
-
- if((BP->BitPlaneSpace[Offset])&Mask)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
-#else
- uint8_t BitPlane_Get(BitPlane * BP, uint16_t X,uint16_t Y);
-#endif
-
-
-void BitPlane_Clear(BitPlane * BP);
-
-#ifdef _INLINE_GFX_GET_PIXEL
-inline uint8_t GFX_GetPixel(RenderContext *Image, int16_t x, int16_t y)
-{
- uint8_t PixelColor = 0;
-
- if((x<Image->SizeX) && (y<Image->SizeY) && (x>=0) && (y>=0))
- {
-
- if(BitPlane_Get(&Image->RenderPlane,x,y))
- PixelColor = 1;
-
- }
-
- return PixelColor;
-}
-#else
- uint8_t GFX_GetPixel(RenderContext *Image, int16_t x, int16_t y);
-#endif
-
-extern RenderContext BackBuffer;
-
-//Two useful fonts!
-extern GFXFont Font5x7;
-extern GFXFont Font3x5;
-
-//values for Red, Green and Blue can be 0-3 (4 levels for each color)
-void SmartSwitch_SetBackLightColor(uint8_t Red,uint8_t Green,uint8_t Blue);
-
#endif
\ No newline at end of file
--- a/main.cpp Mon Aug 31 13:00:37 2020 +0000
+++ b/main.cpp Thu Aug 05 02:12:29 2021 +0000
@@ -13,6 +13,7 @@
#define VT100_WHITE "\033[37;40m"
#define VT100_RESET "\033c"
+extern void WriteRAW_DAC_Value(uint8_t Channel,uint16_t Data);
int main()
{
@@ -21,91 +22,45 @@
//This function always needs called before you do anythign wit the CHEM BOX.
InitChemBox();
+ GREEN_LED = 1;
+ RED_LED = 0;
+
//Beep 6 times
for(i=0;i<6;i++)
{
Buzz(.05); //Since the Buzz function immediately returns we should wait a bit before calling it again in the loop
wait(.1); //I want a 50% duty cycle so I will wait twice as long as my previous Buzz() call
+
+ GREEN_LED = !GREEN_LED;
+ RED_LED = !RED_LED;
+
}
-
+
- //Here is an example of how to draw on the screen!
-
- //This makes the backlight white. Each color can be between 0 and 3 (integers... 0,1,2,3)
- SmartSwitch_SetBackLightColor(3, 3, 3);
-
- //The display routines are fully buffered. When you call the draw routines, the write to the backbuffer, not the screen.
- //The flow is to clear the backbuffer, call all the drawing routines, then dump the backbuffer to the screen.
-
- //This clears the back buffer
- GFX_FullDisplayBufferClear(&BackBuffer);
-
- //Draw a box around the edge of the screen
-
- GFX_DrawLine(&BackBuffer, 0,0, PHYSICAL_DISPLAY_XRES - 1,0);
- GFX_DrawLine(&BackBuffer, PHYSICAL_DISPLAY_XRES - 1,0,PHYSICAL_DISPLAY_XRES - 1 ,PHYSICAL_DISPLAY_YRES - 1);
- GFX_DrawLine(&BackBuffer, PHYSICAL_DISPLAY_XRES - 1 ,PHYSICAL_DISPLAY_YRES - 1,0,PHYSICAL_DISPLAY_YRES - 1);
- GFX_DrawLine(&BackBuffer,0, PHYSICAL_DISPLAY_YRES - 1,0,0);
-
- //Draw a plain string using the 5x7 font.
- GFX_DrawString(&BackBuffer,"Rioux Box",6,2, &Font5x7);
-
- GFX_DrawHline(&BackBuffer,0,PHYSICAL_DISPLAY_XRES - 1 ,12);
-
- //This shows how to do a printf. Using this allows you to put internal variables, etc on the screen.
- //Just lookup documentation on printf on the web to see examples of escape sequences in the control strings
- //In this example API_VERSION is a string so we use %s to display it
- GFX_printf(&BackBuffer,15,20, &Font3x5,"Ver: %s",API_VERSION);
-
- //Move the backbuffer to the actual display
- GFX_DumpRenderContextToPhysicalScreen(&BackBuffer);
-
+ GREEN_LED = 1;
+ RED_LED = 0;
//Here is the main super loop
//reset and start our control loop Timer
ControlLoopTimer.reset();
ControlLoopTimer.start();
-
+
while(1)
{
//Call this often if you want the USB interface/Terminal
ProcessTerminal();
- /*RS232_0.printf(" RUN\r");
+
+
+
+ /*
if(ControlLoopTimer.read_ms() >= 1000)
{
ControlLoopTimer.reset();
PC.printf(VT100_RESET);
-
- for(int channel=0;channel<12;channel++)
- {
- if(channel & 0x01)
- Color = VT100_CYAN;
- else
- Color = VT100_GREEN ;
-
-
- float ThermocoupleTemperature = ReadThermocouple(channel);
- float InternalReferenceTemperature = ReadInternalTemperature(channel);
-
- bool IsDisconnected = (ReadThermocouple_OC() & (1<<channel));
-
- if(IsDisconnected == true)
- {
- PC.printf(VT100_WHITE"Channel %i: ",channel);
- PC.printf(VT100_RED"disconnected\r\n");
- }
- else
- {
- PC.printf(VT100_WHITE"Channel %i: ",channel);
- PC.printf(VT100_WHITE"%s%.2f ",Color,ThermocoupleTemperature);
- PC.printf(VT100_WHITE"INT: ",channel);
- PC.printf(VT100_WHITE"%s%.2f\r\n",Color,InternalReferenceTemperature);
- }
-
- }
+
}*/
Eli Hughes

