BaseMachine Sequencer UI Test

Dependencies:   AverageAnalogIn PinDetect RotaryEncoder Sequence SequencerDisplay mbed-rtos mbed st7565LCD

Fork of CH12864F-SPI2_Test by Ryo Od

Revision:
1:23bc297e8bfe
Parent:
0:cbc508b7ebff
Child:
2:29f0fe703d39
--- a/main.cpp	Fri Aug 05 15:35:42 2016 +0000
+++ b/main.cpp	Wed Aug 17 12:08:31 2016 +0000
@@ -1,16 +1,119 @@
+/*
+ * main.cpp
+ * BaseMachine Sequencer
+ *
+ * 2016.08.17
+ *
+ */
 #include "mbed.h"
+#include "rtos.h"
 #include "st7565LCD.h"
 
+#define UART_TRACE  (1)
+//#include "Sequence.h"
+//#include "ST7565_SequencerDisplay.h"
+
+#define TITLE_STR1  ("BaseMachine Sequencer")
+#define TITLE_STR2  ("20160817")
+
+const int SEQUENCE_N = 16;
+const int PITCH_MAX = 12;
+const int BPM_MIN = 60;
+const int BPM_MAX = 240;
+
 //ST7565(PinName mosi, PinName sclk, PinName cs, PinName rst, PinName a0);
-ST7565 gLCD(PB_15, PB_13, PB_1, PB_2, PB_12);
+ST7565 gLCD(PB_15, PB_13, PB_12, PB_2, PB_1);
+
+AnalogIn AinPulseWidth(PC_2);
+AnalogIn AinCutOff(PB_0);
+AnalogIn AinResonance(PC_1);
+AnalogIn AinEnvMod(PC_3);
+AnalogIn AinLevel(PC_0);
+AnalogIn AinDuration(PA_4);
+AnalogIn AinDecay(PA_1);
+AnalogIn AinSustain(PA_0);
+
+// とりあえずの変数(後でClassのメンバ変数に格納)
+int waveShape = 0;
+int modNumber = 0;
+#define WAVESHAPE_N 2
+#define MOD_NUMBER_MAX 1
+uint8_t pulseWidth;
+uint8_t cutOff;
+uint8_t resonance;
+uint8_t envMod;
+uint8_t level;
+uint8_t duration;
+uint8_t decay;
+uint8_t sustain;
+
+//------------------------------------------------------------------------
+// Functions
+//------------------------------------------------------------------------
+void pollingPots()
+{
+    //pulseWidth = AinPulseWidth.read_u16() >> 8;
+    cutOff     = AinCutOff.read_u16()     >> 8;
+    resonance  = AinResonance.read_u16()  >> 8;
+    //envMod     = AinEnvMod.read_u16()     >> 8;
+    //level      = AinLevel.read_u16()      >> 8;
+    duration   = AinDuration.read_u16()   >> 8;
+    decay      = AinDecay.read_u16()      >> 8;
+    sustain    = AinSustain.read_u16()    >> 8;
+}
+
+void dumpToLCD()
+{
+    char buff[64];
+    int col = 0;
+    
+    gLCD.clear();
+    /*
+    sprintf(buff, "Run: %d", isRunning);
+    gLCD.drawstring(0, col++, buff);
+    sprintf(buff, "BPM: %d", bpm);
+    gLCD.drawstring(0, col++, buff);
+
+    sprintf(buff, "Step: %d", currentStep);
+    gLCD.drawstring(0, col++, buff);
+    sprintf(buff, "NoteOn: %d", sequences[currentStep].noteOn);
+    gLCD.drawstring(0, col++, buff);
+    sprintf(buff, "Pitch: %d", sequences[currentStep].getPitch());
+    gLCD.drawstring(0, col++, buff);
+    sprintf(buff, "Octave: %d", sequences[currentStep].getOctave());
+    gLCD.drawstring(0, col++, buff);
+    sprintf(buff, "Tie: %d", sequences[currentStep].tie);
+    gLCD.drawstring(0, col++, buff);
+    sprintf(buff, "Accent: %d", sequences[currentStep].accent);
+    gLCD.drawstring(0, col++, buff);
+    
+    col = 0;
+    sprintf(buff, "WavS: %d", waveShape);
+    gLCD.drawstring(64, col++, buff);
+    sprintf(buff, "ModN: %d", modNumber);
+    gLCD.drawstring(64, col++, buff);
+    */
+    
+    col = 2;
+    sprintf(buff, "PW%3d CO%3d", pulseWidth, cutOff);
+    gLCD.drawstring(60, col++, buff);
+    sprintf(buff, "RS%3d EV%3d", resonance, envMod);
+    gLCD.drawstring(60, col++, buff);
+    sprintf(buff, "LV%3d DR%3d", level, duration);
+    gLCD.drawstring(60, col++, buff);
+    sprintf(buff, "DC%3d ST%3d", decay, sustain);
+    gLCD.drawstring(60, col++, buff);
+
+    gLCD.display();
+}
 
 int main()
 {
-    gLCD.begin(0x10);
+    printf("\r\n*** BaseMachine Sequencer Test ***\r\n");
+    gLCD.begin(0x10);    
     
     while (true) {
-        gLCD.drawstring(0, 0, "Hello World.");
-        gLCD.display();
-        wait(0.1);
+        pollingPots();
+        dumpToLCD();
     }
 }