Skip to content

Commit

Permalink
fix(sample): update pin name after model changes (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
nedseb committed Oct 8, 2024
1 parent 169a9d5 commit ec45689
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 77 deletions.
6 changes: 3 additions & 3 deletions samples/OOB/buzzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void buzzer_prog()
}

*freq -= p;
buzzer->setAnalogPeriodUs(1000000 / *freq);
buzzer->setAnalogPeriodUs(1'000'000 / *freq);
buzzer->setAnalogValue(255);
});

Expand All @@ -34,7 +34,7 @@ void buzzer_prog()
}

*freq += p;
buzzer->setAnalogPeriodUs(1000000 / *freq);
buzzer->setAnalogPeriodUs(1'000'000 / *freq);
buzzer->setAnalogValue(255);
});

Expand All @@ -50,7 +50,7 @@ void buzzer_prog()
}
});

buzzer->setAnalogPeriodUs(1000000 / *freq);
buzzer->setAnalogPeriodUs(1'000'000 / *freq);
buzzer->setAnalogValue(255);

while (1) {
Expand Down
32 changes: 15 additions & 17 deletions samples/OOB/compass.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ Lis2Data average_measure(unsigned nb_measure)

void compass_prog()
{
float size = 32;
float cx = 64;
float cy = 64;
float size = 32;
float cx = 64;
float cy = 64;
float calib_min_x = std::numeric_limits<float>::max();
float calib_max_x = std::numeric_limits<float>::min();
float calib_min_y = std::numeric_limits<float>::max();
Expand All @@ -63,11 +63,11 @@ void compass_prog()

Lis2Data magn = average_measure(20);

calib_max_x = std::max(calib_max_x, magn.x);
calib_min_x = std::min(calib_min_x, magn.x);
calib_max_x = std::max(calib_max_x, magn.x);
calib_min_x = std::min(calib_min_x, magn.x);

calib_max_y = std::max(calib_max_y, magn.y);
calib_min_y = std::min(calib_min_y, magn.y);
calib_max_y = std::max(calib_max_y, magn.y);
calib_min_y = std::min(calib_min_y, magn.y);
}

printf("Calibration:\n\tx: [%.2f, %.2f]\n\ty: [%.2f, %.2f]\n", calib_min_x, calib_max_x, calib_min_y, calib_max_y);
Expand All @@ -81,16 +81,14 @@ void compass_prog()

float x = mapf(magn.x, calib_min_x, calib_max_x, -1, 1);
float y = -mapf(magn.y, calib_min_y, calib_max_y, -1, 1);
float angle = std::atan2(y, x);


double Acos = cos(angle);
double Asin = sin(angle);
double Bcos = cos(angle - TRI_ANGLE);
double Bsin = sin(angle - TRI_ANGLE);
double Ccos = cos(angle + TRI_ANGLE);
double Csin = sin(angle + TRI_ANGLE);

float angle = std::atan2(y, x);

double Acos = cos(angle);
double Asin = sin(angle);
double Bcos = cos(angle - TRI_ANGLE);
double Bsin = sin(angle - TRI_ANGLE);
double Ccos = cos(angle + TRI_ANGLE);
double Csin = sin(angle + TRI_ANGLE);

ssd->fill(0x00);
ssd->drawCircle(64, 64, 50, false, 0xFF);
Expand Down
68 changes: 34 additions & 34 deletions samples/OOB/oob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,38 +44,38 @@ STM32Pin* led_green = nullptr;
STM32Pin* led_blue = nullptr;
SSD1327_SPI* ssd = nullptr;

STM32Pin* btnMenu = nullptr;
STM32Pin* btnA = nullptr;
STM32Pin* btnB = nullptr;
STM32Pin* buzzer = nullptr;

MCP23009E* mcp = nullptr;
HTS221* hts = nullptr;
WSEN_PADS* pres = nullptr;
VL53L1X* tof = nullptr;
ISM330DL* ism = nullptr;
LIS2MDL* lis = nullptr;

void Demo_OOB(codal::STM32STEAM32_WB55RG& steam32)
STM32Pin* btnMenu = nullptr;
STM32Pin* btnA = nullptr;
STM32Pin* btnB = nullptr;
STM32Pin* buzzer = nullptr;

MCP23009E* mcp = nullptr;
HTS221* hts = nullptr;
WSEN_PADS* pres = nullptr;
VL53L1X* tof = nullptr;
ISM330DL* ism = nullptr;
LIS2MDL* lis = nullptr;

void Demo_OOB(codal::STeaMi& steami)
{
spi = &steam32.spi1;
cs = &steam32.io.PD_0;
dc = &steam32.io.PB_4;
rst = &steam32.io.PA_12;
ssd = new SSD1327_SPI(*spi, *cs, *dc, *rst, 128, 128);
btnMenu = &steam32.io.PA_0;
btnA = &steam32.io.PA_7;
btnB = &steam32.io.PA_8;
buzzer = &steam32.io.PA_11;

led_red = &steam32.io.PC_12;
led_green = &steam32.io.PC_11;
led_blue = &steam32.io.PC_10;
spi = &steami.spiExt;
cs = &steami.io.csDisplay;
dc = &steami.io.misoDisplay;
rst = &steami.io.resetDisplay;
ssd = new SSD1327_SPI(*spi, *cs, *dc, *rst, 128, 128);
btnMenu = &steami.io.buttonMenu;
btnA = &steami.io.buttonA;
btnB = &steami.io.buttonB;
buzzer = &steami.io.speaker;

led_red = &steami.io.ledRed;
led_green = &steami.io.ledGreen;
led_blue = &steami.io.ledBlue;

buzzer->setAnalogValue(0);

steam32.serial.init(115200);
steam32.sleep(500);
steami.serial.init(115'200);
steami.sleep(500);

printf("Init...\r\n");

Expand All @@ -85,33 +85,33 @@ void Demo_OOB(codal::STM32STEAM32_WB55RG& steam32)
ssd->show();

printf("Init. MCP23009E...\n");
mcp = new MCP23009E(steam32.i2c1, 0x40, steam32.io.PB_1, steam32.io.PB_0);
mcp = new MCP23009E(steami.i2cInt, 0x40, steami.io.resetExpander, steami.io.irqExpander);
mcp->setup(MCP_GP_RIGHT, MCP_DIR::INPUT);
mcp->setup(MCP_GP_BOTTOM, MCP_DIR::INPUT);
mcp->setup(MCP_GP_LEFT, MCP_DIR::INPUT);
mcp->setup(MCP_GP_UP, MCP_DIR::INPUT);

printf("Init. HTS221...\n");
hts = new HTS221(&steam32.i2c1, 0xBE);
hts = new HTS221(&steami.i2cInt, 0xBE);
hts->init();
hts->setOutputRate(codal::HTS221_OUTPUT_RATE::RATE_7HZ);

printf("Init. WSEN_PADS...\n");
pres = new WSEN_PADS(steam32.i2c1, 0xBA);
pres = new WSEN_PADS(steami.i2cInt, 0xBA);
pres->init();

printf("Init. VL53L1X...\n");
tof = new VL53L1X(&steam32.i2c1);
tof = new VL53L1X(&steami.i2cInt);
tof->init();

printf("Init. ISM330DL...\n");
ism = new ISM330DL(&steam32.i2c1);
ism = new ISM330DL(&steami.i2cInt);
ism->init();
ism->setAccelerometerODR(ISM_ODR::F_1_66_KHZ);
ism->setGyroscopeODR(ISM_ODR::F_208_HZ);

printf("Init. LIS2MDL...\n");
lis = new LIS2MDL(&steam32.i2c1);
lis = new LIS2MDL(&steami.i2cInt);
lis->init();

unsigned select_prog = 0;
Expand Down
6 changes: 3 additions & 3 deletions samples/OOB/oob.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once
#include "STM32STEAM32_WB55RG.h"
#include "STeaMi.h"

#ifndef SAMPLE_MAIN
#define SAMPLE_MAIN Demo_OOB
#define SAMPLE_MAIN Demo_OOB
#endif

void Demo_OOB(codal::STM32STEAM32_WB55RG& steam32);
void Demo_OOB(codal::STeaMi& steami);
3 changes: 1 addition & 2 deletions samples/OOB/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ std::string fToStr(float value, unsigned pres)
bool click_button(codal::STM32Pin* btn)
{
if (btn->getDigitalValue() == 0) {
while (btn->getDigitalValue() == 0)
;
while (btn->getDigitalValue() == 0);

return true;
}
Expand Down
36 changes: 18 additions & 18 deletions samples/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,41 @@
#include "STeaMi.h"

#if defined(BUTTONS_SAMPLE)
#include "ButtonSample.h"
#include "ButtonSample.h"
#elif defined(SERIAL_SAMPLE)
#include "SerialSample.h"
#include "SerialSample.h"
#elif defined(SIGLE_WIRE_SERIAL_SAMPLE)
#include "SingleWireSerialSample.h"
#include "SingleWireSerialSample.h"
#elif defined(SAI_SAMPLE)
#include "SAI_sample.h"
#include "SAI_sample.h"
#elif defined(VL53L1X_SAMPLE)
#include "VL53L1X_sample.h"
#include "VL53L1X_sample.h"
#elif defined(HTS221_SAMPLE)
#include "HTS221_sample.h"
#include "HTS221_sample.h"
#elif defined(WSEN_PADS_SAMPLE)
#include "WSEN-PADS_sample.h"
#include "WSEN-PADS_sample.h"
#elif defined(SCANNER_I2C)
#include "ScannerI2C.h"
#include "ScannerI2C.h"
#elif defined(OLED_SSD1327)
#include "OLED_SSD1327.h"
#include "OLED_SSD1327.h"
#elif defined(APDS9960)
#include "APDS9960_sample.h"
#include "APDS9960_sample.h"
#elif defined(BQ27441)
#include "BQ27441_sample.h"
#include "BQ27441_sample.h"
#elif defined(RTC_SAMPLE)
#include "RTC_sample.h"
#include "RTC_sample.h"
#elif defined(DAPLINK_FLASH)
#include "DapLink_Flash_sample.h"
#include "DapLink_Flash_sample.h"
#elif defined(DEMO)
#include "demo_sample.h"
#include "demo_sample.h"
#elif defined(FUS_WS_OPERATOR)
#include "FUS_WS_Operator.h"
#include "FUS_WS_Operator.h"
#elif defined(BLE_BROADCAST)
#include "BLE_Broadcast_Sample.h"
#include "BLE_Broadcast_Sample.h"
#elif defined(OOB)
#include "oob.h"
#include "oob.h"
#else
#include "BlinkSample.h"
#include "BlinkSample.h"
#endif

codal::STeaMi steami;
Expand Down

0 comments on commit ec45689

Please sign in to comment.