BaseMachine UI Controllerに分離

Dependencies:   AverageAnalogIn PinDetect RotaryEncoder Sequence SequencerDisplay mbed-rtos mbed st7567LCD BaseMachineComon

Fork of BaseMachine_Sequencer by Ryo Od

Revision:
53:cad31fd61d8a
Parent:
52:72332a596bc5
Child:
54:38187ac44253
--- a/main.cpp	Sun Oct 16 03:59:07 2016 +0000
+++ b/main.cpp	Sun Oct 23 05:33:37 2016 +0000
@@ -15,37 +15,18 @@
 #include "AverageAnalogIn.h"
 
 #define UART_TRACE  (1)
+#include "BaseMachineCommon.h"
 #include "Sequence.h"
 #include "ST7565_SequencerDisplay.h"
 
 #define TITLE_STR1  ("BaseMachine UI Controller")
-#define TITLE_STR2  ("20161011")
+#define TITLE_STR2  ("20161023")
 
-#define SEQUENCE_N  (16)
-#define SPI1_RATE   (3000000)
 #define SPI2_RATE   (1000000)
 #define POT_RESOLUTION      (7)     // bit
-#define AIN_AVERAGE         (32)    // AnalogInを移動平均する要素数
-#define POLLING_POTS_WAIT   (5)    // POT読み取りThreadのWait値(ミリ秒)
+#define AIN_AVERAGE         (16)     // AnalogInを移動平均する要素数
+#define POLLING_POTS_WAIT   (20)    // POT読み取りThreadのWait値(ミリ秒)
 
-enum SequencerCmd {
-    CMD_RCV_PLAYING_STEP = 0x01,
-    CMD_RUN              = 0x11,
-    CMD_BPM              = 0x12,
-    CMD_ACCENT_LEVEL     = 0x13,
-    CMD_WAVE_SHAPE       = 0x21,
-    CMD_PULSE_WIDTH      = 0x22,
-    CMD_CUTOFF           = 0x31,
-    CMD_RESONANCE        = 0x32,
-    CMD_LEVEL            = 0x41,
-    CMD_DURATION         = 0x42,
-    CMD_DECAY            = 0x43,
-    CMD_SUSTAIN          = 0x44,
-    CMD_NOTE             = 0x51,
-    CMD_PITCH            = 0x52, 
-};
-
-const int baseNoteNumber = 36;
 const int bpmMax = 240;
 const int bpmMin = 60;
 const int octaveMax = 2;
@@ -53,18 +34,16 @@
 const int waveShapeMax = 1;
 const int UImodeMax = 2;
 
-// Initial Sequence
-const int noteOn[SEQUENCE_N] = { 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0 };
-const int pitch[SEQUENCE_N]  = {36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36 };
-const int tie[SEQUENCE_N]    = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-const int accent[SEQUENCE_N] = { 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 };
-
 // Devices
 //
+
+//RESET Line
+//DigitalOut ResetLine();
+
 //SPI (PinName mosi, PinName miso, PinName sclk, PinName ssel=NC)
 SPI SpiMaster(PA_7, PA_6, PA_5);
 DigitalOut SpiMasterCs(PB_6);
-InterruptIn stepChangeInterrupt(PC_7);
+InterruptIn StepChangeInterrupt(PC_7);
 
 //ST7565(PinName mosi, PinName sclk, PinName cs, PinName rst, PinName a0);
 ST7565 gLCD(PB_15, PB_13, PB_12, PB_2, PB_1);
@@ -605,9 +584,9 @@
     // 
     SpiMasterCs = 1;
     SpiMaster.format(16, 0);
-    SpiMaster.frequency(SPI1_RATE);
+    SpiMaster.frequency(SPI_UI_TO_SEQUENCER_RATE);
     
-    stepChangeInterrupt.fall(&updateStep);
+    StepChangeInterrupt.fall(&updateStep);
     
     //--------------------------------------------------------------------
     // Initialize objects