Skip to content

Commit

Permalink
1.0.1 with examples
Browse files Browse the repository at this point in the history
  • Loading branch information
marchingband committed Jul 15, 2021
1 parent 60920e1 commit 5806571
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 35 deletions.
35 changes: 7 additions & 28 deletions examples/wvr_basic/wvr_basic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,19 @@
#include <rpc.h>
#include <file_system.h>
#include <wvr_0.3.h>
#include <gpio.h>

WVR wvr;
Button btn1(D2, FALLING, 300);

bool serverOn = true;

void on1(void)
{
// wvr.play(0,40,127);
if(serverOn)
{
log_i("server pause");
wvr.serverPause();
log_i("wifi on %d", get_metadata()->wifi_starts_on);
}
else
{
log_i("server resume");
wvr.serverResume();
log_i("wifi on %d", get_metadata()->wifi_starts_on);
}
serverOn = !serverOn;
}

void setup() {
// put your setup code here, to run once:
wvr.useFTDI = false;
wvr.useUsbMidi = false;
wvr.begin();
serverOn = get_metadata()->wifi_starts_on;
log_i("wifi on %d", serverOn);
pinMode(D2, INPUT_PULLUP);
btn1.onPress(on1);
wvr.wifiIsOn = get_metadata()->wifi_starts_on;
log_i("wifi is %s", wvr.wifiIsOn ? "on" : "off");
}

void loop() {
// put your main code here, to run repeatedly:
vTaskDelay(portMAX_DELAY);
// vTaskDelay(portMAX_DELAY);
vTaskDelete(NULL);
}
28 changes: 28 additions & 0 deletions examples/wvr_usb/wvr_usb.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <wvr_pins.h>
#include <button_struct.h>
#include <ws_log.h>
#include <wvr_ui.h>
#include <WVR.h>
#include <midiXparser.h>
#include <midi_in.h>
#include <wav_player.h>
#include <button.h>
#include <rpc.h>
#include <file_system.h>
#include <wvr_0.3.h>
#include <gpio.h>

WVR wvr;

void setup() {
wvr.useFTDI = false;
wvr.useUsbMidi = true;
wvr.begin();
wvr.wifiIsOn = get_metadata()->wifi_starts_on;
log_i("wifi is %s", wvr.wifiIsOn ? "on" : "off");
}

void loop() {
// vTaskDelay(portMAX_DELAY);
vTaskDelete(NULL);
}
19 changes: 13 additions & 6 deletions src/gpio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,17 @@ void on_press_per_config(int pin_num)
void wvr_gpio_init(bool useFTDI, bool useUsbMidi)
{
log_i("useFTDI is %d",useFTDI);
int start = useFTDI ? useUsbMidi ? 3 : 2 : 0;
log_i("gpio start is %d",start);
for(int i=start;i<14;i++)
log_i("useUsbMidi is %d",useUsbMidi);
for(int i=0;i<14;i++)
{
if(
((i == 0) && useFTDI) ||
((i == 1) && useFTDI) ||
((i == 2) && useUsbMidi)
)
{
continue;
}
gpio_num_t gpio_num = gpio_pins[i];
int pin_num = wvr_pins[i];
pin_config_t pin = pin_config_lut[i];
Expand All @@ -126,18 +133,18 @@ void wvr_gpio_init(bool useFTDI, bool useUsbMidi)
else if(pin.edge == EDGE_FALLING)
{
pinMode(pin_num, INPUT_PULLUP);
buttons[i] = new Button(pin_num, FALLING, pin.debounce);
buttons[i] = new Button(pin_num, FALLING, pin.debounce); // digital constructor
}
else if(pin.edge == EDGE_RISING)
{
pinMode(pin_num, INPUT_PULLUP);
buttons[i] = new Button(pin_num, RISING, pin.debounce);
buttons[i] = new Button(pin_num, RISING, pin.debounce); // digital constructor
}
}
else
{
// touch mode
buttons[i] = new Button(pin_num, FALLING, pin.debounce, true);
buttons[i] = new Button(pin_num, FALLING, pin.debounce, true); // touch constructor
}
}
if(buttons[0] != NULL) buttons[0]->onPress([](){on_press_per_config(0);});
Expand Down
2 changes: 1 addition & 1 deletion src/wvr_0.3.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// #include "WVR.h"

#define VERSION_CODE "1.0.0"
#define VERSION_CODE "1.0.1"

void wvr_init(bool useFTDI, bool useUsbMidi);

Expand Down

0 comments on commit 5806571

Please sign in to comment.