From bfa639d5a2a832d4189cc04b668ca6176e6a5f8f Mon Sep 17 00:00:00 2001 From: Mike C Date: Tue, 9 Apr 2013 17:40:12 -0400 Subject: [PATCH] Added shifter code --- Universal_Serial_Adapter/Config.cpp | 19 +++++++++++++++++++ Universal_Serial_Adapter/Config.h | 5 ++++- Universal_Serial_Adapter/Project.h | 11 +++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Universal_Serial_Adapter/Config.cpp b/Universal_Serial_Adapter/Config.cpp index 0d521d0..12adbca 100644 --- a/Universal_Serial_Adapter/Config.cpp +++ b/Universal_Serial_Adapter/Config.cpp @@ -8,6 +8,8 @@ attribute. */ +#include "Arduino.h" + #include "Project.h" #include "Config.h" @@ -70,6 +72,23 @@ void Config::setLineSpeed(linespeed speed) { void Config::setVoltage(ttlvoltage voltage) { currentVoltage = voltage; + int shiftNumber = shiftOff; + switch (voltage) { + case 1: // onePointEight + shiftNumber = shift18V; + break; + case 2: // threePointThree + shiftNumber = shift33V; + break; + case 3: // five + shiftNumber = shift50V; + break; + } + + // Use bit shifter to activate the proper voltage regulator + digitalWrite(shifterLatchPin, LOW); + shiftOut(shifterDataPin, shifterClockPin, MSBFIRST, shiftNumber); + digitalWrite(shifterLatchPin, HIGH); } void Config::setTimeout(timeout aTimeout) { diff --git a/Universal_Serial_Adapter/Config.h b/Universal_Serial_Adapter/Config.h index 53bc94d..54fbd94 100644 --- a/Universal_Serial_Adapter/Config.h +++ b/Universal_Serial_Adapter/Config.h @@ -22,7 +22,10 @@ private: timeout currentTimeout; bool uiEnabled; - + const static int shiftOff = 0; + const static int shift18V = 1; + const static int shift33V = 2; + const static int shift50V = 4; public: Config(); diff --git a/Universal_Serial_Adapter/Project.h b/Universal_Serial_Adapter/Project.h index df00414..f1b09b3 100644 --- a/Universal_Serial_Adapter/Project.h +++ b/Universal_Serial_Adapter/Project.h @@ -13,20 +13,27 @@ #define DEBUG true // For controlling debug output via serial -// Pinout / things that need configuration +// Buttons / Joystick / Input Hardware Pinouts #define okButtonPin 22 #define okButtonLed 23 #define cancelButtonPin 24 #define cancelButtonLed 25 #define pspXPin 0 // After GND / @ edge #define pspYPin 1 // Between VCC and gnd -// LCD Pinouts + +// LCD Pinout #define LCD_LITE 26 // Backlight pin #define SD_CS 7 // Chip select line for SD card #define LCD_CS 53 // Chip select line for TFT display #define LCD_DC 9 // Data/command line for TFT #define LCD_RST 8 // Reset line for TFT (or connect to +5V) +// 74HC595 Bit Shifter Pinout +#define shifterLatchPin 2 //Pin connected to ST_CP of 74HC595 +#define shifterClockPin 5 //Pin connected to SH_CP of 74HC595 +#define shifterDataPin 4 //Pin connected to DS of 74HC595 + +// Colors / theme of UI #define SPLASH_BACKGROUND ST7735_WHITE #define BACKGROUND ST7735_BLACK #define TEXT ST7735_WHITE