Commit 6dc7fcd2 authored by philip's avatar philip
Browse files

cfg and button functionality

parent e0e1849c
......@@ -12,13 +12,14 @@ https://aggregat.zhdk.ch/
- [ ] [mDNS / DNS-SD](https://github.com/tschiemer/minimr) based host/service discovery
- [x] ~~using hardware id as part of hostname~~
- [ ] ~~dynamic, simple hostname~~
- [ ] *Proposed* Use Channel (or specific) setting as part of hostname, ex ch4.aggregat.local or 1.aggregat.local
- [ ] *Proposed* Use Channel (or specific) setting as part of hostname, ex ch4.aggregat.local or 1.aggregat.local
- [ ] service???
- [ ] Control interface TBD
1. *Proposed* Raw UDP (quasi simple) port (?): 1234 (?)
2. [OSC](https://github.com/MariadeAnton/oscpack) (relatively simple)
3. *Postpone (when components are made by pt)* RTPMIDI (complex)
## Installation / Flashing
1. Connect the USB cable (programming end / opposite of ethernet plug) to computer.
......@@ -85,6 +86,29 @@ or
![iocontrols board](https://gitlab.zhdk.ch/aggregat-02/a01-firmware/-/raw/master/docs/iocontrols-labelled.png)
| What | Function |
| --- | --- |
| Button left corner | Hard reset |
| 4-pin DIP Switch left | MIDI channel select (binary MSB-LSB) |
| 4-pin DIP Switch right | Device id select (binary MSB-LSB) |
| 8-pin DIP Switch: Pin 1 | Forward USBMIDI to MIDI? |
| 8-pin DIP Switch: Pin 2 | Forward USBMIDI to RTPMIDI? |
| 8-pin DIP Switch: Pin 3 | Forward MIDI to USBMIDI? |
| 8-pin DIP Switch: Pin 4 | Forward MIDI to RTPMIDI? |
| 8-pin DIP Switch: Pin 5 | Forward RTPMIDI to USBMIDI? |
| 8-pin DIP Switch: Pin 6 | Forward RTPMIDI to MIDI? |
| 8-pin DIP Switch: Pin 7 | HIGH -> Suspend motors on startup, LOW -> run motors |
| 8-pin DIP Switch: Pin 8 | Enable motor power control (MIDI commands are processed) *currently feature not implemented in hardware* |
| Three buttons left | Set all motors to center position |
| Three buttons middle | *not implemented* |
| Three buttons right | Suspend / Resume all motors |
| |
| Green LED left bottom | System has power |
| Red LED left top | Motors are either all suspended or at least one motor's power is off |
| LED
## Software
Use [Mbed Studio](https://os.mbed.com/studio/) as IDE.
......
......@@ -401,17 +401,26 @@ void motors_resume()
void motors_run()
{
if (btn_plus2_touched){
if (motors_running){
motors_suspend();
} else {
motors_resume();
}
btn_plus2_touched = false;
}
if (motors_center_request){
motors_center();
motors_center_request = false;
}
bool is_off = !motors_running;
bool is_off = motors_running == false;
for(int i = 0; i < MOTOR_COUNT; i++){
motors[i].run();
// is_off |= !motors[i].get_state();
is_off |= motors[i].get_state() == false;
}
led_motors = is_off;
......@@ -491,15 +500,22 @@ void controller_handle_msg(uint8_t * buffer, size_t length, Source source)
#endif //USE_PITCHBEND_CONTROL
// power control
if (msg.type() == MIDIMessage::NoteOnType || msg.type() == MIDIMessage::NoteOffType){
if (msg.channel() == get_channel()){
int32_t motori = msg.key();
if (0 <= motori && motori < MOTOR_COUNT){
// turn on or off
bool off = msg.type() == MIDIMessage::NoteOffType || msg.velocity() == 0;
// printf("motor pwr %d := %d\n", motori, !off);
motors[motori] = !off;
#if USE_CFG
// only enable power pin iff cfg2 is enabled
if (cfg2.read()){
#else
{
#endif
if (msg.type() == MIDIMessage::NoteOnType || msg.type() == MIDIMessage::NoteOffType){
if (msg.channel() == get_channel()){
int32_t motori = msg.key();
if (0 <= motori && motori < MOTOR_COUNT){
// turn on or off
bool off = msg.type() == MIDIMessage::NoteOffType || msg.velocity() == 0;
// printf("motor pwr %d := %d\n", motori, !off);
motors[motori] = !off;
}
}
}
}
......@@ -1087,7 +1103,14 @@ int main()
netmidi_init();
// start motors
// motors_resume();
#if USE_CFG
// if cfg1 is low, resume (all switches (default) low -> system should run without further ado)
if (!cfg1.read()){
motors_resume();
}
#else
motors_resume();
#endif //USE_CFG
while (true) {
usbmidi_run();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment