I'm in the process of building a dual lab power supply with and the Stellaris should provide monitoring and protection shutdown.
I've ported the Adafruit LCD library to Energia LM4F (it should be easy to port to MSP430 as well) so I'm using that to display stuff in graphical format.
The code below does a few tricks that might be useful for some of you: a rolling buffer to hold the data, automatic vertical scaling between the minimum and maximum values.
As always, any kind of feedback is appreciated, I'm still a beginner.
A picture is worth a thousand words. I only have 5 points of resolution in this picture but the vertical scale is actually 20 points.
// Include application, user and local libraries#include "inc/hw_memmap.h"#include "inc/hw_types.h"#include "driverlib/debug.h"#include "driverlib/sysctl.h"#include "driverlib/adc.h"#include "Energia.h"#include <Adafruit_GFX.h>#include <Adafruit_PCD8544.h>// pin 7 - Serial clock out (SCLK)// pin 6 - Serial data out (DIN)// pin 5 - Data/Command select (D/C)// pin 4 - LCD chip select (CS)// pin 3 - LCD reset (RST)Adafruit_PCD8544 display = Adafruit_PCD8544(PC_5, PC_6, PC_7, PD_6, PD_7);#define RBUFFER_SIZE LCDWIDTH#define PIXEL_DOUBLING 0#define PIXELS_INSTEAD_OF_LINES 0int32_t voltages[RBUFFER_SIZE];void initThermometer(){SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);SysCtlADCSpeedSet(SYSCTL_ADCSPEED_125KSPS); // 250ADCSequenceDisable(ADC0_BASE, 1);ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS);ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_TS);ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_TS);ADCSequenceStepConfigure(ADC0_BASE, 1, 3, ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END);ADCSequenceEnable(ADC0_BASE, 1);}int32_t getTempAdcValue(){unsigned long ulADC0Value[4];ADCIntClear(ADC0_BASE, 1);ADCProcessorTrigger(ADC0_BASE, 1);while(!ADCIntStatus(ADC0_BASE, 1, false)){}ADCSequenceDataGet(ADC0_BASE, 1, ulADC0Value);unsigned long ulTempAvg = (ulADC0Value[0] + ulADC0Value[1] + ulADC0Value[2] + ulADC0Value[3] + 2)/4;int32_t ulTempValueC = 1475 - ((2475 * ulTempAvg)) / 4096;return ulTempValueC;}// Add setup codevoid setup() {pinMode(PC_4, OUTPUT);digitalWrite(PC_4, HIGH);//vccpinMode(PF_3, OUTPUT);digitalWrite(PF_3, LOW);//vsspinMode(PB_3, OUTPUT);digitalWrite(PB_3, LOW);//leddisplay.begin();display.setContrast(50);display.clearDisplay(); // clears the screen and bufferinitThermometer();Serial.begin(9600);}// Display maskchar temptext[8] = {' ', ' ', ' ', '.', ' ', 0x7f, 'C', 0x00};int32_t minScale;int32_t maxScale;void appendToBuffer(int32_t buffer[], int32_t value){//roll the buffer one value forwardfor (uint8_t i=1; i<RBUFFER_SIZE; i++){buffer[i-1] = buffer[i];}//replace last positionbuffer[RBUFFER_SIZE-1] = value;}void drawBuffer(uint8_t xpos, uint8_t ypos, uint8_t bufferHeight){minScale = 9999999; //TODOmaxScale = -9999999;// retrieve min and max valuesfor (uint8_t i=0; i<RBUFFER_SIZE; i++){minScale = min(voltages[i],minScale);maxScale = max(voltages[i],maxScale);}uint8_t lastX = xpos;uint8_t lastY = ypos;//draw pixelsfor (uint8_t i=0; i<RBUFFER_SIZE; i++){uint8_t x = xpos + i;uint8_t y = ypos + bufferHeight - (bufferHeight*(voltages[i]-minScale)/(maxScale-minScale));if (PIXEL_DOUBLING && (i%2==0)){//produces artifacts, rolling buffer increment should be set to 2 to avoid it}else{if (PIXELS_INSTEAD_OF_LINES){display.drawPixel(x, y, BLACK);}else{display.drawLine(lastX, lastY, x, y, BLACK);}lastX = x;lastY = y;}}}uint8_t ypos = 20;uint8_t bufferHeight = 20;// Add loop codevoid loop() {int32_t number = getTempAdcValue();appendToBuffer(voltages, number);display.clearDisplay();//draw graph first so it stays underdrawBuffer(0, ypos, 20);//min and max scale texts{display.setTextSize(1);display.setTextColor(WHITE, BLACK);display.setCursor(0, ypos+bufferHeight-6);display.print((float)minScale/10,1);display.setCursor(0, ypos);display.print((float)maxScale/10,1);}//large readoutdisplay.setTextSize(2);display.setTextColor(BLACK);display.setCursor(0,0);display.print((float)number/10,1);display.print('C');display.display();delay(200);}