├── examples ├── Wippersnapper_demo │ ├── .magtag.generate │ ├── .qtpy_esp32.generate │ ├── .feather_esp32.generate │ ├── .feather_esp32s2.generate │ ├── .feather_esp32s3.generate │ ├── .feather_esp8266.generate │ ├── .funhouse.test.skip │ ├── .metro_esp32s3.generate │ ├── .metroesp32s2.generate │ ├── .mkrwifi1010.test.skip │ ├── .nano_33_iot.test.skip │ ├── .qtpy_esp32c3.generate │ ├── .qtpy_esp32s2.generate │ ├── .qtpy_esp32s3.generate │ ├── .xiao_esp32s3.generate │ ├── .dfrobot_beetle_esp32c3.generate │ ├── .esp32s3_devkitc_1_n8.generate │ ├── .feather_esp32_v2.generate │ ├── .feather_esp32s2_tft.generate │ ├── .feather_esp32s3_tft.generate │ ├── .funhouse_noota.generate │ ├── .itsybitsy_esp32.generate │ ├── .picow_rp2040_tinyusb.generate │ ├── .qtpy_esp32s3_n4r2.generate │ ├── .sparklemotion_esp32.generate │ ├── .feather_esp32s2_debug.test.skip │ ├── .feather_esp32s3_debug.test.skip │ ├── .metro_esp32s3_debug.test.skip │ ├── .metroesp32s2_debug.test.skip │ ├── .picow_rp2350_tinyusb.generate │ ├── .sparklemotionmini_esp32.generate │ ├── .sparklemotionstick_esp32.generate │ ├── .esp32s3_devkitc_1_n8_debug.test.skip │ ├── .feather_esp32_s3_reverse_tft.generate │ ├── .feather_esp32s2_reverse_tft.generate │ ├── .feather_esp32s2_tft_debug.test.skip │ ├── .feather_esp32s3_reverse_tft.generate │ ├── .fruit_jam_tinyusb.generate │ ├── .pyportal_tinyusb.generate │ ├── .wippersnapper_feather_esp32.generate │ ├── .wippersnapper_feather_esp32c6.generate │ ├── .wippersnapper_qtpy_esp32c3.generate │ ├── .espressif_esp32c5_devkitc_1_n8r4.generate │ ├── .feather_esp32_s3_reverse_tft_dev.test.skip │ ├── .feather_esp32s3_4mbflash_2mbpsram.generate │ ├── .feather_esp32s3_reverse_tft_debug.test.skip │ ├── .feather_esp32s3_tft_debug.test.skip │ ├── .metro_m4_airliftlite_tinyusb.generate │ ├── .pyportal_titano_tinyusb.generate │ ├── .espressif_esp32c5_devkitc_1_n8r4_debug.test.skip │ ├── .feather_esp32s3_4mbflash_2mbpsram_debug.test.skip │ ├── .wippersnapper_feather_esp32c6_debug.test.skip │ ├── .wippersnapper_feather_esp32s3_reverse_tft.generate │ ├── .wippersnapper_feather_esp32s3_reverse_tft_debug.test.skip │ └── Wippersnapper_demo.ino ├── wippersnapper_debug │ ├── .magtag.test.skip │ ├── .feather_esp32.test.skip │ ├── .funhouse.test.skip │ ├── .metro_esp32s3.test.skip │ ├── .metroesp32s2.test.skip │ ├── .mkrwifi1010.test.skip │ ├── .nano_33_iot.test.skip │ ├── .qtpy_esp32.test.skip │ ├── .qtpy_esp32c3.test.skip │ ├── .qtpy_esp32s2.test.skip │ ├── .qtpy_esp32s3.test.skip │ ├── .xiao_esp32s3.test.skip │ ├── .dfrobot_beetle_esp32c3.test.skip │ ├── .feather_esp32_v2.test.skip │ ├── .feather_esp32s2.test.skip │ ├── .feather_esp32s2_dev.generate │ ├── .feather_esp32s3.test.skip │ ├── .feather_esp32s3_dev.generate │ ├── .feather_esp8266.test.skip │ ├── .feather_s2_tinyusb.test.skip │ ├── .itsybitsy_esp32.test.skip │ ├── .metro_esp32s3_debug.generate │ ├── .metroesp32s2_debug.generate │ ├── .qtpy_esp32s3_n4r2.test.skip │ ├── .esp32s3_devkitc_1_n8.test.skip │ ├── .feather_esp32_v2_debug.test.skip │ ├── .feather_esp32s2_debug.generate │ ├── .feather_esp32s2_tft.test.skip │ ├── .feather_esp32s3_tft.test.skip │ ├── .funhouse_noota.test.skip │ ├── .picow_rp2040_tinyusb.test.skip │ ├── .picow_rp2350_tinyusb.test.skip │ ├── .sparklemotion_esp32.test.skip │ ├── .sparklemotionmini_esp32.test.skip │ ├── .esp32s3_devkitc_1_n8_debug.generate │ ├── .feather_esp32s2_reverse_tft.test.skip │ ├── .feather_esp32s3_debug.generate │ ├── .feather_esp32s3_reverse_tft.test.skip │ ├── .fruit_jam_tinyusb.test.skip │ ├── .pyportal_tinyusb.test.skip │ ├── .sparklemotionstick_esp32.test.skip │ ├── .wippersnapper_feather_esp32.test.skip │ ├── .wippersnapper_qtpy_esp32c3.test.skip │ ├── .espressif_esp32c5_devkitc_1_n8r4.test.skip │ ├── .feather_esp32_s3_reverse_tft_dev.generate │ ├── .feather_esp32s2_tft_debug.generate │ ├── .feather_esp32s3_4mbflash_2mbpsram.test.skip │ ├── .feather_esp32s3_reverse_tft_debug.generate │ ├── .feather_esp32s3_reverse_tft_dev.generate │ ├── .feather_esp32s3_tft_debug.generate │ ├── .metro_m4_airliftlite_tinyusb.test.skip │ ├── .pyportal_titano_tinyusb.test.skip │ ├── .wippersnapper_feather_esp32c6.test.skip │ ├── .espressif_esp32c5_devkitc_1_n8r4_debug.generate │ ├── .feather_esp32s3_4mbflash_2mbpsram_debug.generate │ ├── .wippersnapper_feather_esp32c6_debug.generate │ ├── .wippersnapper_feather_esp32s3_reverse_tft_debug.generate │ ├── .wippersnapper_feather_esp32s3_reverse_tft.test.skip │ └── wippersnapper_debug.ino └── secrets-examples │ ├── secrets-wifi.json │ └── README.md ├── .gitmodules ├── src ├── .vscode │ └── settings.json ├── components │ ├── ledc │ │ ├── drivers │ │ │ ├── README.txt │ │ │ └── servo │ │ │ │ └── ws_ledc_servo.h │ │ ├── ws_ledc.h │ │ └── ws_ledc.cpp │ ├── i2c │ │ └── drivers │ │ │ ├── WipperSnapper_I2C_Driver_QMC5883P.h │ │ │ ├── WipperSnapper_I2C_Driver_INA260.h │ │ │ ├── WipperSnapper_I2C_Driver_INA228.h │ │ │ ├── WipperSnapper_I2C_Driver_INA238.h │ │ │ ├── WipperSnapper_I2C_Driver_INA237.h │ │ │ ├── WipperSnapper_I2C_Driver_TMP117.h │ │ │ ├── WipperSnapper_I2C_Driver_ADT7410.h │ │ │ ├── WipperSnapper_I2C_Driver_MCP9808.h │ │ │ ├── WipperSnapper_I2C_Driver_PCT2075.h │ │ │ ├── WipperSnapper_I2C_Driver_MPRLS.h │ │ │ ├── WipperSnapper_I2C_Driver_INA260.cpp │ │ │ ├── WipperSnapper_I2C_Driver_QMC5883P.cpp │ │ │ ├── WipperSnapper_I2C_Driver_VEML7700.h │ │ │ ├── WipperSnapper_I2C_Driver_HTU31D.h │ │ │ ├── WipperSnapper_I2C_Driver_HTU21D.h │ │ │ ├── WipperSnapper_I2C_Driver_VL53L0X.h │ │ │ ├── WipperSnapper_I2C_Driver_BH1750.h │ │ │ ├── WipperSnapper_I2C_Driver_SHTC3.h │ │ │ ├── WipperSnapper_I2C_Driver_VCNL4020.h │ │ │ ├── WipperSnapper_I2C_Driver_MAX17048.h │ │ │ ├── WipperSnapper_I2C_Driver_VL53L1X.h │ │ │ ├── WipperSnapper_I2C_Driver_TSL2591.h │ │ │ ├── WipperSnapper_I2C_Driver_SHT4X.h │ │ │ ├── WipperSnapper_I2C_Driver_INA219.h │ │ │ ├── WipperSnapper_I2C_Driver_MPL115A2.h │ │ │ ├── WipperSnapper_I2C_Driver_INA228.cpp │ │ │ ├── WipperSnapper_I2C_Driver_SI7021.h │ │ │ ├── WipperSnapper_I2C_Driver_SHT3X.h │ │ │ ├── WipperSnapper_I2C_Driver_LPS3XHW.h │ │ │ ├── WipperSnapper_I2C_Driver_INA237.cpp │ │ │ ├── WipperSnapper_I2C_Driver_INA238.cpp │ │ │ ├── WipperSnapper_I2C_Driver_STEMMA_Soil_Sensor.h │ │ │ └── WipperSnapper_I2C_Driver_HTS221.h │ ├── pwm │ │ └── ws_pwm.h │ ├── display │ │ ├── controller.h │ │ ├── hardware.h │ │ └── assets │ │ │ └── icons.h │ ├── digitalIO │ │ └── Wippersnapper_DigitalGPIO.h │ ├── ds18x20 │ │ └── ws_ds18x20.h │ ├── servo │ │ └── ws_servo.h │ ├── uart │ │ └── ws_uart.h │ ├── pixels │ │ └── ws_pixels.h │ ├── statusLED │ │ └── Wippersnapper_StatusLED.h │ └── analogIO │ │ └── Wippersnapper_AnalogIO.h ├── print_dependencies.h ├── print_dependencies.cpp ├── wippersnapper │ ├── servo │ │ └── v1 │ │ │ └── servo.pb.c │ ├── ds18x20 │ │ └── v1 │ │ │ └── ds18x20.pb.c │ ├── pixels │ │ └── v1 │ │ │ └── pixels.pb.c │ ├── uart │ │ └── v1 │ │ │ └── uart.pb.c │ ├── pwm │ │ └── v1 │ │ │ └── pwm.pb.c │ ├── description │ │ └── v1 │ │ │ └── description.pb.c │ ├── pin │ │ └── v1 │ │ │ └── pin.pb.c │ ├── display │ │ └── v1 │ │ │ └── display.pb.c │ ├── signal │ │ └── v1 │ │ │ └── signal.pb.c │ └── i2c │ │ └── v1 │ │ └── i2c.pb.c ├── nanopb │ ├── ws_pb_helpers.h │ ├── pb_common.h │ └── ws_pb_helpers.cpp ├── Wippersnapper_demo.ino ├── provisioning │ ├── ConfigJson.h │ ├── Config.h │ ├── littlefs │ │ └── WipperSnapper_LittleFS.h │ ├── tinyusb │ │ ├── Wippersnapper_FS.h │ │ └── fatfs │ │ │ └── diskio.h │ └── ConfigJson.cpp └── Wippersnapper_Networking.h ├── rename_usb_config.py ├── .github ├── workflows │ ├── release-caller.yml │ └── release-callee.yml └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── .vscode └── settings.json ├── .gitignore ├── LICENSE ├── library.properties └── README.md /examples/Wippersnapper_demo/.magtag.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.qtpy_esp32.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.magtag.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp32.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp32s2.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp32s3.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp8266.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.funhouse.test.skip: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.metro_esp32s3.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.metroesp32s2.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.mkrwifi1010.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.nano_33_iot.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.qtpy_esp32c3.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.qtpy_esp32s2.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.qtpy_esp32s3.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.xiao_esp32s3.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.funhouse.test.skip: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.metro_esp32s3.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.metroesp32s2.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.mkrwifi1010.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.nano_33_iot.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.qtpy_esp32.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.qtpy_esp32c3.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.qtpy_esp32s2.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.qtpy_esp32s3.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.xiao_esp32s3.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.dfrobot_beetle_esp32c3.generate: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.esp32s3_devkitc_1_n8.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp32_v2.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp32s2_tft.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp32s3_tft.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.funhouse_noota.generate: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.itsybitsy_esp32.generate: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.picow_rp2040_tinyusb.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.qtpy_esp32s3_n4r2.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.sparklemotion_esp32.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.dfrobot_beetle_esp32c3.test.skip: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32_v2.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32s2.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32s2_dev.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32s3.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32s3_dev.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp8266.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_s2_tinyusb.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.itsybitsy_esp32.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.metro_esp32s3_debug.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.metroesp32s2_debug.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.qtpy_esp32s3_n4r2.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp32s2_debug.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp32s3_debug.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.metro_esp32s3_debug.test.skip: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.metroesp32s2_debug.test.skip: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.picow_rp2350_tinyusb.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.sparklemotionmini_esp32.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.sparklemotionstick_esp32.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.esp32s3_devkitc_1_n8.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32_v2_debug.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32s2_debug.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32s2_tft.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32s3_tft.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.funhouse_noota.test.skip: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.picow_rp2040_tinyusb.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.picow_rp2350_tinyusb.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.sparklemotion_esp32.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.sparklemotionmini_esp32.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.esp32s3_devkitc_1_n8_debug.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp32_s3_reverse_tft.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp32s2_reverse_tft.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp32s2_tft_debug.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp32s3_reverse_tft.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.fruit_jam_tinyusb.generate: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.pyportal_tinyusb.generate: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.wippersnapper_feather_esp32.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.wippersnapper_feather_esp32c6.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.wippersnapper_qtpy_esp32c3.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.esp32s3_devkitc_1_n8_debug.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32s2_reverse_tft.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32s3_debug.generate: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32s3_reverse_tft.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.fruit_jam_tinyusb.test.skip: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.pyportal_tinyusb.test.skip: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.sparklemotionstick_esp32.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.wippersnapper_feather_esp32.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.wippersnapper_qtpy_esp32c3.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.espressif_esp32c5_devkitc_1_n8r4.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp32_s3_reverse_tft_dev.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp32s3_4mbflash_2mbpsram.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp32s3_reverse_tft_debug.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp32s3_tft_debug.test.skip: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.metro_m4_airliftlite_tinyusb.generate: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.pyportal_titano_tinyusb.generate: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.espressif_esp32c5_devkitc_1_n8r4.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32_s3_reverse_tft_dev.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32s2_tft_debug.generate: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32s3_4mbflash_2mbpsram.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32s3_reverse_tft_debug.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32s3_reverse_tft_dev.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32s3_tft_debug.generate: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.metro_m4_airliftlite_tinyusb.test.skip: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.pyportal_titano_tinyusb.test.skip: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.wippersnapper_feather_esp32c6.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.espressif_esp32c5_devkitc_1_n8r4_debug.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.feather_esp32s3_4mbflash_2mbpsram_debug.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.wippersnapper_feather_esp32c6_debug.test.skip: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.espressif_esp32c5_devkitc_1_n8r4_debug.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.feather_esp32s3_4mbflash_2mbpsram_debug.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.wippersnapper_feather_esp32c6_debug.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.wippersnapper_feather_esp32s3_reverse_tft_debug.generate: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.wippersnapper_feather_esp32s3_reverse_tft.generate: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/.wippersnapper_feather_esp32s3_reverse_tft.test.skip: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/.wippersnapper_feather_esp32s3_reverse_tft_debug.test.skip: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tools/uf2"] 2 | path = tools/uf2 3 | url = https://github.com/microsoft/uf2.git 4 | -------------------------------------------------------------------------------- /src/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.dimInactiveRegions": false, 3 | "files.associations": { 4 | "__config": "cpp" 5 | } 6 | } -------------------------------------------------------------------------------- /src/components/ledc/drivers/README.txt: -------------------------------------------------------------------------------- 1 | These files are drivers that interface directly with WipperSnapper's ESP32 LEDC peripheral manager, `ws_ledc`. -------------------------------------------------------------------------------- /src/print_dependencies.h: -------------------------------------------------------------------------------- 1 | #ifndef PROJECT_DEPENDENCIES_H 2 | #define PROJECT_DEPENDENCIES_H 3 | 4 | #define PRINT_DEPENDENCIES 0 5 | extern const char *project_dependencies; 6 | #endif // PROJECT_DEPENDENCIES_H -------------------------------------------------------------------------------- /examples/secrets-examples/secrets-wifi.json: -------------------------------------------------------------------------------- 1 | { 2 | "io_username": "YOUR_IO_USERNAME_HERE", 3 | "io_key": "YOUR_IO_KEY_HERE", 4 | "network_type_wifi": { 5 | "network_ssid": "YOUR_WIFI_SSID_HERE", 6 | "network_password": "YOUR_WIFI_PASS_HERE" 7 | } 8 | } -------------------------------------------------------------------------------- /src/print_dependencies.cpp: -------------------------------------------------------------------------------- 1 | #include "print_dependencies.h" 2 | 3 | const char *project_dependencies = R"( 4 | Libraries and Versions: 5 | ** This is a placeholder, you can fill this in automatically by running arduino-cli and copying the output here. ** 6 | 7 | Platforms and Versions: 8 | ** Board Support Package placeholder ** 9 | )"; -------------------------------------------------------------------------------- /examples/secrets-examples/README.md: -------------------------------------------------------------------------------- 1 | ## secrets.json Examples 2 | 3 | This folder contains templates for the `secrets.json` configuration file used by WipperSnapper's filesystem-backed-provisioning. This provisioning is only available to hardware compatible with TinyUSB. 4 | 5 | Each `.json` file contains Adafruit IO credentials and a single `network_type` object used to define a network interface's type and specific properties. -------------------------------------------------------------------------------- /rename_usb_config.py: -------------------------------------------------------------------------------- 1 | # Renames tinyusb's tusb_config.h to tusb_config.h_backup for PlatformIO build environments using TinyUSB 2 | # https://github.com/platformio/platform-espressif32/issues/809#issuecomment-1132079120 3 | import os 4 | 5 | Import("env") 6 | 7 | adafruit_usb_config = os.path.join( 8 | env.subst("$PROJECT_LIBDEPS_DIR"), 9 | env.subst("$PIOENV"), 10 | "Adafruit TinyUSB Library", 11 | "src", 12 | "tusb_config.h", 13 | ) 14 | 15 | if os.path.isfile(adafruit_usb_config): 16 | os.rename(adafruit_usb_config, adafruit_usb_config + "_backup") -------------------------------------------------------------------------------- /.github/workflows/release-caller.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Brent Rubell for Adafruit Industries, 2022 2 | # 3 | # SPDX-License-Identifier: MIT 4 | name: WipperSnapper Release Workflow 5 | 6 | on: 7 | release: 8 | types: [published] 9 | secrets: 10 | GH_REPO_TOKEN: 11 | required: true 12 | 13 | jobs: 14 | call-workflow-build: 15 | uses: adafruit/Adafruit_Wippersnapper_Arduino/.github/workflows/build-clang-doxy.yml@main 16 | secrets: 17 | GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }} 18 | 19 | call-workflow-release: 20 | needs: call-workflow-build 21 | uses: adafruit/Adafruit_Wippersnapper_Arduino/.github/workflows/release-callee.yml@main 22 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "limits": "c", 4 | "type_traits": "c", 5 | "array": "cpp", 6 | "deque": "cpp", 7 | "list": "cpp", 8 | "string": "cpp", 9 | "unordered_map": "cpp", 10 | "unordered_set": "cpp", 11 | "vector": "cpp", 12 | "string_view": "cpp", 13 | "format": "cpp", 14 | "initializer_list": "cpp", 15 | "span": "cpp" 16 | }, 17 | "C_Cpp.dimInactiveRegions": true, 18 | "dotnet.defaultSolution": "disable", 19 | "cmake.configureOnOpen": false, 20 | "C_Cpp.clang_format_fallbackStyle": "Google", 21 | "C_Cpp.clang_format_style": "file" 22 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for WipperSnapper Arduino 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /examples/wippersnapper_debug/wippersnapper_debug.ino: -------------------------------------------------------------------------------- 1 | // Adafruit IO WipperSnapper Beta (DEBUG BUILD ONLY!) 2 | // Brent Rubell for Adafruit Industries, 2021 - 2023 3 | 4 | #include "Wippersnapper_Networking.h" 5 | Wippersnapper_WiFi wipper; 6 | 7 | // Enable debug output for beta builds 8 | #define WS_DEBUG 9 | 10 | void setup() { 11 | // Provisioning must occur prior to serial init. 12 | wipper.provision(); 13 | 14 | Serial.begin(115200); // wippersnapper serial 15 | Serial1.begin(115200); // ESP-IDF messages serial 16 | Serial1.setDebugOutput(true); // Enable ESP-IDF messages over Serial1 17 | //while (!Serial) delay(10); 18 | 19 | wipper.connect(); 20 | } 21 | 22 | void loop() { 23 | wipper.run(); 24 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Doxygen 35 | *.bak 36 | html/* 37 | 38 | 39 | # VSCode artifacts 40 | .vscode/* 41 | src/.vscode/settings.json 42 | 43 | .DS_STORE 44 | 45 | examples/Wippersnapper_demo/build/ 46 | 47 | # Platformio artifacts 48 | .pio/ 49 | 50 | # Secrets 51 | data/ 52 | 53 | # Misc. Data 54 | tests/ 55 | venv/ 56 | 57 | Doxyfile -------------------------------------------------------------------------------- /src/wippersnapper/servo/v1/servo.pb.c: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.5-dev at Tue Sep 30 14:06:15 2025. */ 3 | 4 | #include "wippersnapper/servo/v1/servo.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(wippersnapper_servo_v1_ServoAttachRequest, wippersnapper_servo_v1_ServoAttachRequest, AUTO) 10 | 11 | 12 | PB_BIND(wippersnapper_servo_v1_ServoAttachResponse, wippersnapper_servo_v1_ServoAttachResponse, AUTO) 13 | 14 | 15 | PB_BIND(wippersnapper_servo_v1_ServoDetachRequest, wippersnapper_servo_v1_ServoDetachRequest, AUTO) 16 | 17 | 18 | PB_BIND(wippersnapper_servo_v1_ServoWriteRequest, wippersnapper_servo_v1_ServoWriteRequest, AUTO) 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/wippersnapper/ds18x20/v1/ds18x20.pb.c: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.5-dev at Tue Sep 30 14:06:15 2025. */ 3 | 4 | #include "wippersnapper/ds18x20/v1/ds18x20.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(wippersnapper_ds18x20_v1_Ds18x20InitRequest, wippersnapper_ds18x20_v1_Ds18x20InitRequest, AUTO) 10 | 11 | 12 | PB_BIND(wippersnapper_ds18x20_v1_Ds18x20InitResponse, wippersnapper_ds18x20_v1_Ds18x20InitResponse, AUTO) 13 | 14 | 15 | PB_BIND(wippersnapper_ds18x20_v1_Ds18x20DeInitRequest, wippersnapper_ds18x20_v1_Ds18x20DeInitRequest, AUTO) 16 | 17 | 18 | PB_BIND(wippersnapper_ds18x20_v1_Ds18x20DeviceEvent, wippersnapper_ds18x20_v1_Ds18x20DeviceEvent, AUTO) 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/wippersnapper/pixels/v1/pixels.pb.c: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.5-dev at Tue Sep 30 14:06:15 2025. */ 3 | 4 | #include "wippersnapper/pixels/v1/pixels.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(wippersnapper_pixels_v1_PixelsCreateRequest, wippersnapper_pixels_v1_PixelsCreateRequest, AUTO) 10 | 11 | 12 | PB_BIND(wippersnapper_pixels_v1_PixelsCreateResponse, wippersnapper_pixels_v1_PixelsCreateResponse, AUTO) 13 | 14 | 15 | PB_BIND(wippersnapper_pixels_v1_PixelsDeleteRequest, wippersnapper_pixels_v1_PixelsDeleteRequest, AUTO) 16 | 17 | 18 | PB_BIND(wippersnapper_pixels_v1_PixelsWriteRequest, wippersnapper_pixels_v1_PixelsWriteRequest, AUTO) 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.github/workflows/release-callee.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Brent Rubell for Adafruit Industries, 2022 2 | # 3 | # SPDX-License-Identifier: MIT 4 | name: WipperSnapper Release Callee 5 | 6 | on: 7 | workflow_call: 8 | 9 | jobs: 10 | release-wippersnapper: 11 | name: Release WipperSnapper 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Download build artifacts from build-platform steps 15 | uses: actions/download-artifact@v4 16 | with: 17 | path: . 18 | - name: List Files 19 | run: ls 20 | - name: Upload Assets to the GitHub Release 21 | uses: softprops/action-gh-release@v2 22 | if: startsWith(github.ref, 'refs/tags/') 23 | with: 24 | files: | 25 | build-files/wippersnapper.*.uf2 26 | build-files/wippersnapper.*.bin 27 | build-files/wippersnapper.*.zip 28 | -------------------------------------------------------------------------------- /src/wippersnapper/uart/v1/uart.pb.c: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.5-dev at Tue Sep 30 14:06:15 2025. */ 3 | 4 | #include "wippersnapper/uart/v1/uart.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(wippersnapper_uart_v1_UARTBusData, wippersnapper_uart_v1_UARTBusData, AUTO) 10 | 11 | 12 | PB_BIND(wippersnapper_uart_v1_UARTDeviceAttachRequest, wippersnapper_uart_v1_UARTDeviceAttachRequest, AUTO) 13 | 14 | 15 | PB_BIND(wippersnapper_uart_v1_UARTDeviceAttachResponse, wippersnapper_uart_v1_UARTDeviceAttachResponse, AUTO) 16 | 17 | 18 | PB_BIND(wippersnapper_uart_v1_UARTDeviceDetachRequest, wippersnapper_uart_v1_UARTDeviceDetachRequest, AUTO) 19 | 20 | 21 | PB_BIND(wippersnapper_uart_v1_UARTDeviceEvent, wippersnapper_uart_v1_UARTDeviceEvent, AUTO) 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/nanopb/ws_pb_helpers.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file ws_pb_helpers.h 3 | * 4 | * Protobuf encode/decode helpers with error logging for Wippersnapper. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Tyeth Gundry 2024 for Adafruit Industries. 11 | * 12 | * BSD license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef WS_PB_ENCODE_H 16 | #define WS_PB_ENCODE_H 17 | 18 | #include "pb.h" 19 | #include "pb_decode.h" 20 | #include "pb_encode.h" 21 | 22 | bool ws_pb_decode(pb_istream_t *stream, const pb_msgdesc_t *fields, 23 | void *dest_struct); 24 | 25 | bool ws_pb_encode(pb_ostream_t *stream, const pb_msgdesc_t *fields, 26 | const void *src_struct); 27 | 28 | #endif // WS_PB_ENCODE_H -------------------------------------------------------------------------------- /src/Wippersnapper_demo.ino: -------------------------------------------------------------------------------- 1 | // Adafruit IO WipperSnapper Beta 2 | // 3 | // 4 | // NOTE: This software is a BETA release and in active development. 5 | // Please report bugs or errors to https://github.com/adafruit/Adafruit_Wippersnapper_Arduino/issues 6 | // 7 | // 8 | // Adafruit invests time and resources providing this open source code. 9 | // Please support Adafruit and open source hardware by purchasing 10 | // products from Adafruit! 11 | // 12 | // Brent Rubell for Adafruit Industries, 2021-2022 13 | // 14 | // All text above must be included in any redistribution. 15 | 16 | #include "Wippersnapper_Networking.h" 17 | Wippersnapper_WiFi wipper; 18 | 19 | // Enable debug output for beta builds 20 | #define WS_DEBUG 21 | 22 | void setup() { 23 | // Provisioning must occur prior to serial init. 24 | wipper.provision(); 25 | 26 | Serial.begin(115200); 27 | // while (!Serial) delay(10); 28 | 29 | wipper.connect(); 30 | 31 | } 32 | 33 | void loop() { 34 | wipper.run(); 35 | } -------------------------------------------------------------------------------- /examples/Wippersnapper_demo/Wippersnapper_demo.ino: -------------------------------------------------------------------------------- 1 | // Adafruit IO WipperSnapper Beta 2 | // 3 | // 4 | // NOTE: This software is a BETA release and in active development. 5 | // Please report bugs or errors to https://github.com/adafruit/Adafruit_Wippersnapper_Arduino/issues 6 | // 7 | // 8 | // Adafruit invests time and resources providing this open source code. 9 | // Please support Adafruit and open source hardware by purchasing 10 | // products from Adafruit! 11 | // 12 | // Brent Rubell for Adafruit Industries, 2021-2022 13 | // 14 | // All text above must be included in any redistribution. 15 | 16 | #include "Wippersnapper_Networking.h" 17 | Wippersnapper_WiFi wipper; 18 | 19 | // Enable debug output for beta builds 20 | #define WS_DEBUG 21 | 22 | void setup() { 23 | // Provisioning must occur prior to serial init. 24 | wipper.provision(); 25 | 26 | Serial.begin(115200); 27 | //while (!Serial) delay(10); 28 | 29 | wipper.connect(); 30 | 31 | } 32 | 33 | void loop() { 34 | wipper.run(); 35 | } -------------------------------------------------------------------------------- /src/provisioning/ConfigJson.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file ConfigJson.h 3 | * 4 | * Wippersnapper JSON secretsConfig File Converters 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Brent Rubell 2024 for Adafruit Industries. 11 | * 12 | * BSD license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef CONFIGJSON_H 16 | #define CONFIGJSON_H 17 | #define ARDUINOJSON_USE_DOUBLE 0 18 | #define ARDUINOJSON_USE_LONG_LONG 1 19 | #include "Config.h" 20 | #include 21 | 22 | // Converters for network configuration 23 | void convertToJson(const networkConfig &src, JsonVariant dst); 24 | void convertFromJson(JsonVariantConst src, networkConfig &dst); 25 | // Converters for secrets configuration 26 | void convertToJson(const secretsConfig &src, JsonVariant dst); 27 | void convertFromJson(JsonVariantConst src, secretsConfig &dst); 28 | #endif // CONFIGJSON_H -------------------------------------------------------------------------------- /src/wippersnapper/pwm/v1/pwm.pb.c: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.5-dev at Tue Sep 30 14:06:15 2025. */ 3 | 4 | #include "wippersnapper/pwm/v1/pwm.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(wippersnapper_pwm_v1_PWMAttachRequest, wippersnapper_pwm_v1_PWMAttachRequest, AUTO) 10 | 11 | 12 | PB_BIND(wippersnapper_pwm_v1_PWMAttachResponse, wippersnapper_pwm_v1_PWMAttachResponse, AUTO) 13 | 14 | 15 | PB_BIND(wippersnapper_pwm_v1_PWMDetachRequest, wippersnapper_pwm_v1_PWMDetachRequest, AUTO) 16 | 17 | 18 | PB_BIND(wippersnapper_pwm_v1_PWMWriteDutyCycleRequest, wippersnapper_pwm_v1_PWMWriteDutyCycleRequest, AUTO) 19 | 20 | 21 | PB_BIND(wippersnapper_pwm_v1_PWMWriteDutyCycleMultiRequest, wippersnapper_pwm_v1_PWMWriteDutyCycleMultiRequest, AUTO) 22 | 23 | 24 | PB_BIND(wippersnapper_pwm_v1_PWMWriteFrequencyRequest, wippersnapper_pwm_v1_PWMWriteFrequencyRequest, AUTO) 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/provisioning/Config.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file secretsConfig.h 3 | * 4 | * Contains user-defined structures for WipperSnapper JSON configuration files. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Brent Rubell 2024 for Adafruit Industries. 11 | * 12 | * BSD license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef CONFIG_H 16 | #define CONFIG_H 17 | struct networkConfig { 18 | char ssid[32]; 19 | char pass[64]; 20 | }; 21 | 22 | struct secretsConfig { 23 | networkConfig network; 24 | char aio_url[64]; 25 | char aio_user[31]; 26 | char aio_key[41]; 27 | int io_port; 28 | float status_pixel_brightness; 29 | }; 30 | 31 | struct displayConfigSPI { 32 | int pinCs; 33 | int pinDc; 34 | int pinMosi; 35 | int pinSck; 36 | int pinRst; 37 | }; 38 | 39 | struct displayConfig { 40 | char driver[10]; 41 | int width; 42 | int height; 43 | int rotation; 44 | displayConfigSPI spiConfig; 45 | }; 46 | #endif // CONFIG_H -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020-2021 Adafruit Industries 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/wippersnapper/description/v1/description.pb.c: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.5-dev at Tue Sep 30 14:06:15 2025. */ 3 | 4 | #include "wippersnapper/description/v1/description.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(wippersnapper_description_v1_CreateDescriptionRequest, wippersnapper_description_v1_CreateDescriptionRequest, AUTO) 10 | 11 | 12 | PB_BIND(wippersnapper_description_v1_CreateDescriptionRequest_Version, wippersnapper_description_v1_CreateDescriptionRequest_Version, AUTO) 13 | 14 | 15 | PB_BIND(wippersnapper_description_v1_CreateDescriptionResponse, wippersnapper_description_v1_CreateDescriptionResponse, AUTO) 16 | 17 | 18 | PB_BIND(wippersnapper_description_v1_RegistrationComplete, wippersnapper_description_v1_RegistrationComplete, AUTO) 19 | 20 | 21 | PB_BIND(wippersnapper_description_v1_GetDefinitionRequest, wippersnapper_description_v1_GetDefinitionRequest, AUTO) 22 | 23 | 24 | PB_BIND(wippersnapper_description_v1_GetDefinitionResponse, wippersnapper_description_v1_GetDefinitionResponse, AUTO) 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_QMC5883P.h 3 | * 4 | * Driver wrapper for the Adafruit QMC5883P 3-axis magnetometer. 5 | * 6 | * Publishes magnetic field magnitude in Gauss as SENSOR_TYPE_MAGNETIC_FIELD. 7 | */ 8 | #ifndef WipperSnapper_I2C_Driver_QMC5883P_H 9 | #define WipperSnapper_I2C_Driver_QMC5883P_H 10 | 11 | #include "WipperSnapper_I2C_Driver.h" 12 | #include "Wippersnapper.h" 13 | 14 | class Adafruit_QMC5883P; // forward 15 | 16 | /**************************************************************************/ 17 | /*! 18 | @brief Class that provides a driver interface for a QMC5883P sensor. 19 | */ 20 | /**************************************************************************/ 21 | class WipperSnapper_I2C_Driver_QMC5883P : public WipperSnapper_I2C_Driver { 22 | public: 23 | WipperSnapper_I2C_Driver_QMC5883P(TwoWire *i2c, uint16_t sensorAddress); 24 | ~WipperSnapper_I2C_Driver_QMC5883P(); 25 | 26 | bool begin(); 27 | bool getEventRaw(sensors_event_t *magEvent); 28 | 29 | private: 30 | Adafruit_QMC5883P *_qmc = nullptr; ///< Pointer to the QMC5883P sensor object 31 | }; 32 | 33 | #endif // WipperSnapper_I2C_Driver_QMC5883P_H 34 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve WipperSnapper Arduino 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | ***Arduino board*** 14 | INSERT ARDUINO BOARD NAME/TYPE HERE 15 | 16 | **To Reproduce** 17 | Steps to reproduce the behavior: 18 | 1. Go to '...' 19 | 2. Click on '....' 20 | 3. Scroll down to '....' 21 | 4. See error 22 | 23 | **Expected behavior** 24 | A clear and concise description of what you expected to happen. 25 | 26 | **Which components are connected to your device** 27 | Which components are set up on the WipperSnapper device page? 28 | 29 | **Screenshots** 30 | If applicable, add screenshots to help explain your problem. 31 | 32 | **Desktop (please complete the following information):** 33 | - OS: [e.g. iOS] 34 | - Browser [e.g. chrome, safari] 35 | - Version [e.g. 22] 36 | 37 | **Smartphone (please complete the following information):** 38 | - Device: [e.g. iPhone6] 39 | - OS: [e.g. iOS8.1] 40 | - Browser [e.g. stock browser, safari] 41 | - Version [e.g. 22] 42 | 43 | **Additional context** 44 | Add any other context about the problem here. 45 | -------------------------------------------------------------------------------- /src/provisioning/littlefs/WipperSnapper_LittleFS.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Wippersnapper_LittleFS.h 3 | * 4 | * Interfaces with LittleFS filesystem for ESP32, ESP8266 platforms. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Brent Rubell 2021-2024 for Adafruit Industries. 11 | * 12 | * BSD license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef WIPPERSNAPPER_LITTLEFS_H 16 | #define WIPPERSNAPPER_LITTLEFS_H 17 | 18 | #include "Wippersnapper.h" 19 | 20 | #include 21 | #include 22 | 23 | // forward decl. 24 | class Wippersnapper; 25 | 26 | /***************************************************************************/ 27 | /*! 28 | @brief Class that handles WipperSnapper's LittleFS filesystem. 29 | */ 30 | /***************************************************************************/ 31 | class WipperSnapper_LittleFS { 32 | public: 33 | WipperSnapper_LittleFS(); 34 | ~WipperSnapper_LittleFS(); 35 | void parseSecrets(); 36 | void fsHalt(String msg); 37 | }; 38 | 39 | extern Wippersnapper WS; 40 | #endif // WIPPERSNAPPER_LITTLEFS_H -------------------------------------------------------------------------------- /src/wippersnapper/pin/v1/pin.pb.c: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.5-dev at Tue Sep 30 14:06:15 2025. */ 3 | 4 | #include "wippersnapper/pin/v1/pin.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(wippersnapper_pin_v1_ConfigurePinRequests, wippersnapper_pin_v1_ConfigurePinRequests, AUTO) 10 | 11 | 12 | PB_BIND(wippersnapper_pin_v1_ConfigurePinRequest, wippersnapper_pin_v1_ConfigurePinRequest, AUTO) 13 | 14 | 15 | PB_BIND(wippersnapper_pin_v1_PinEvent, wippersnapper_pin_v1_PinEvent, AUTO) 16 | 17 | 18 | PB_BIND(wippersnapper_pin_v1_ConfigureReferenceVoltage, wippersnapper_pin_v1_ConfigureReferenceVoltage, AUTO) 19 | 20 | 21 | PB_BIND(wippersnapper_pin_v1_PinEvents, wippersnapper_pin_v1_PinEvents, AUTO) 22 | 23 | 24 | PB_BIND(wippersnapper_pin_v1_ConfigurePWMPinRequest, wippersnapper_pin_v1_ConfigurePWMPinRequest, AUTO) 25 | 26 | 27 | PB_BIND(wippersnapper_pin_v1_ConfigurePWMPinRequests, wippersnapper_pin_v1_ConfigurePWMPinRequests, AUTO) 28 | 29 | 30 | PB_BIND(wippersnapper_pin_v1_PWMPinEvent, wippersnapper_pin_v1_PWMPinEvent, AUTO) 31 | 32 | 33 | PB_BIND(wippersnapper_pin_v1_PWMPinEvents, wippersnapper_pin_v1_PWMPinEvents, AUTO) 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/wippersnapper/display/v1/display.pb.c: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.5-dev at Tue Sep 30 14:06:15 2025. */ 3 | 4 | #include "wippersnapper/display/v1/display.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(wippersnapper_display_v1_EpdSpiConfig, wippersnapper_display_v1_EpdSpiConfig, AUTO) 10 | 11 | 12 | PB_BIND(wippersnapper_display_v1_EPDConfig, wippersnapper_display_v1_EPDConfig, AUTO) 13 | 14 | 15 | PB_BIND(wippersnapper_display_v1_TftSpiConfig, wippersnapper_display_v1_TftSpiConfig, AUTO) 16 | 17 | 18 | PB_BIND(wippersnapper_display_v1_TftConfig, wippersnapper_display_v1_TftConfig, AUTO) 19 | 20 | 21 | PB_BIND(wippersnapper_display_v1_DisplayAddOrReplace, wippersnapper_display_v1_DisplayAddOrReplace, AUTO) 22 | 23 | 24 | PB_BIND(wippersnapper_display_v1_DisplayRemove, wippersnapper_display_v1_DisplayRemove, AUTO) 25 | 26 | 27 | PB_BIND(wippersnapper_display_v1_DisplayWrite, wippersnapper_display_v1_DisplayWrite, 2) 28 | 29 | 30 | PB_BIND(wippersnapper_display_v1_DisplayAddedOrReplaced, wippersnapper_display_v1_DisplayAddedOrReplaced, AUTO) 31 | 32 | 33 | PB_BIND(wippersnapper_display_v1_DisplayRemoved, wippersnapper_display_v1_DisplayRemoved, AUTO) 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/components/pwm/ws_pwm.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file ws_servo.h 3 | * 4 | * High-level interface for wippersnapper to manage servo objects 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * 11 | * Brent Rubell for Adafruit Industries 2022 12 | * 13 | * 14 | * MIT license, all text here must be included in any redistribution. 15 | * 16 | */ 17 | #ifndef WS_PWM 18 | #define WS_PWM 19 | 20 | #include "Wippersnapper.h" 21 | 22 | #ifdef ARDUINO_ARCH_ESP32 23 | #include "components/ledc/ws_ledc.h" 24 | #endif 25 | 26 | class Wippersnapper; 27 | class ws_ledc; 28 | 29 | /**************************************************************************/ 30 | /*! 31 | @brief Interface for WipperSnapper PWM 32 | */ 33 | /**************************************************************************/ 34 | class ws_pwm { 35 | public: 36 | ws_pwm(); 37 | ws_pwm(ws_ledc *ledcManager); 38 | ~ws_pwm(); 39 | bool attach(uint8_t pin, double freq, uint8_t resolution); 40 | void detach(uint8_t pin); 41 | void writeDutyCycle(uint8_t pin, int dutyCycle); 42 | void writeTone(uint8_t pin, uint32_t freq); 43 | void noTone(uint8_t pin); 44 | 45 | private: 46 | ws_ledc *_ledcMgr = nullptr; ///< pointer to ws_ledc 47 | }; 48 | extern Wippersnapper WS; 49 | 50 | #endif // WS_PWM -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_INA260.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_INA260.h 3 | * 4 | * Device driver for the INA260 DC Current and Voltage Monitor 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Tyeth Gundry 2025 for Adafruit Industries. 11 | * 12 | * MIT license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef WipperSnapper_I2C_Driver_INA260_H 16 | #define WipperSnapper_I2C_Driver_INA260_H 17 | 18 | #include "WipperSnapper_I2C_Driver.h" 19 | 20 | // Forward declaration 21 | class Adafruit_INA260; 22 | 23 | /**************************************************************************/ 24 | /*! 25 | @brief Class that provides a driver interface for a INA260 sensor. 26 | */ 27 | /**************************************************************************/ 28 | class WipperSnapper_I2C_Driver_INA260 : public WipperSnapper_I2C_Driver { 29 | public: 30 | WipperSnapper_I2C_Driver_INA260(TwoWire *i2c, uint16_t sensorAddress); 31 | ~WipperSnapper_I2C_Driver_INA260(); 32 | 33 | bool begin(); 34 | bool getEventVoltage(sensors_event_t *voltageEvent); 35 | bool getEventCurrent(sensors_event_t *currentEvent); 36 | 37 | protected: 38 | Adafruit_INA260 *_ina260 = nullptr; ///< Pointer to INA260 sensor object 39 | }; 40 | 41 | #endif // WipperSnapper_I2C_Driver_INA260 -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_INA228.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_INA228.h 3 | * 4 | * Device driver for the INA228 High Precision DC Current and Voltage Monitor 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Tyeth Gundry 2025 for Adafruit Industries. 11 | * 12 | * MIT license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef WipperSnapper_I2C_Driver_INA228_H 16 | #define WipperSnapper_I2C_Driver_INA228_H 17 | 18 | #include "WipperSnapper_I2C_Driver.h" 19 | #include "Wippersnapper.h" 20 | 21 | // Forward declaration 22 | class Adafruit_INA228; 23 | 24 | /**************************************************************************/ 25 | /*! 26 | @brief Class that provides a driver interface for a INA228 sensor. 27 | */ 28 | /**************************************************************************/ 29 | class WipperSnapper_I2C_Driver_INA228 : public WipperSnapper_I2C_Driver { 30 | public: 31 | WipperSnapper_I2C_Driver_INA228(TwoWire *i2c, uint16_t sensorAddress); 32 | ~WipperSnapper_I2C_Driver_INA228(); 33 | 34 | bool begin(); 35 | bool getEventVoltage(sensors_event_t *voltageEvent); 36 | bool getEventCurrent(sensors_event_t *currentEvent); 37 | bool getEventRaw(sensors_event_t *powerEvent); 38 | 39 | protected: 40 | Adafruit_INA228 *_ina228; ///< Pointer to INA228 sensor object 41 | }; 42 | 43 | #endif // WipperSnapper_I2C_Driver_INA228_H 44 | -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_INA238.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_INA238.h 3 | * 4 | * Device driver for the INA238 High-precision DC Current and Voltage Monitor 5 | * 16-bit ADC with ±0.1% gain error, ±5µV offset voltage 6 | * Higher precision version compared to INA237 7 | * 8 | * Adafruit invests time and resources providing this open source code, 9 | * please support Adafruit and open-source hardware by purchasing 10 | * products from Adafruit! 11 | * 12 | * Copyright (c) Tyeth Gundry 2025 for Adafruit Industries. 13 | * 14 | * MIT license, all text here must be included in any redistribution. 15 | * 16 | */ 17 | #ifndef WipperSnapper_I2C_Driver_INA238_H 18 | #define WipperSnapper_I2C_Driver_INA238_H 19 | 20 | #include "WipperSnapper_I2C_Driver.h" 21 | 22 | // Forward declaration 23 | class Adafruit_INA238; 24 | 25 | /**************************************************************************/ 26 | /*! 27 | @brief Class that provides a driver interface for a INA238 sensor. 28 | */ 29 | /**************************************************************************/ 30 | class WipperSnapper_I2C_Driver_INA238 : public WipperSnapper_I2C_Driver { 31 | public: 32 | WipperSnapper_I2C_Driver_INA238(TwoWire *i2c, uint16_t sensorAddress); 33 | ~WipperSnapper_I2C_Driver_INA238(); 34 | 35 | bool begin(); 36 | bool getEventVoltage(sensors_event_t *voltageEvent); 37 | bool getEventCurrent(sensors_event_t *currentEvent); 38 | bool getEventRaw(sensors_event_t *powerEvent); 39 | 40 | protected: 41 | Adafruit_INA238 *_ina238; ///< Pointer to INA238 sensor object 42 | }; 43 | 44 | #endif // WipperSnapper_I2C_Driver_INA238 -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_INA237.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_INA237.h 3 | * 4 | * Device driver for the INA237 DC Current and Voltage Monitor 5 | * 16-bit ADC with ±0.3% gain error, ±50µV offset voltage 6 | * Cost-effective version, lower precision than INA238 7 | * 8 | * Adafruit invests time and resources providing this open source code, 9 | * please support Adafruit and open-source hardware by purchasing 10 | * products from Adafruit! 11 | * 12 | * Copyright (c) Tyeth Gundry 2025 for Adafruit Industries. 13 | * 14 | * MIT license, all text here must be included in any redistribution. 15 | * 16 | */ 17 | #ifndef WipperSnapper_I2C_Driver_INA237_H 18 | #define WipperSnapper_I2C_Driver_INA237_H 19 | 20 | #include "WipperSnapper_I2C_Driver.h" 21 | #include "Wippersnapper.h" 22 | 23 | // Forward declaration 24 | class Adafruit_INA237; 25 | 26 | /**************************************************************************/ 27 | /*! 28 | @brief Class that provides a driver interface for a INA237 sensor. 29 | */ 30 | /**************************************************************************/ 31 | class WipperSnapper_I2C_Driver_INA237 : public WipperSnapper_I2C_Driver { 32 | public: 33 | WipperSnapper_I2C_Driver_INA237(TwoWire *i2c, uint16_t sensorAddress); 34 | ~WipperSnapper_I2C_Driver_INA237(); 35 | 36 | bool begin(); 37 | bool getEventVoltage(sensors_event_t *voltageEvent); 38 | bool getEventCurrent(sensors_event_t *currentEvent); 39 | bool getEventRaw(sensors_event_t *powerEvent); 40 | 41 | protected: 42 | Adafruit_INA237 *_ina237; ///< Pointer to INA237 sensor object 43 | }; 44 | 45 | #endif // WipperSnapper_I2C_Driver_INA237 -------------------------------------------------------------------------------- /src/components/display/controller.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file src/components/display/controller.h 3 | * 4 | * Controller for the display API 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Brent Rubell 2025 for Adafruit Industries. 11 | * 12 | * BSD license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef WS_DISPLAY_CONTROLLER_H 16 | #define WS_DISPLAY_CONTROLLER_H 17 | #include "Wippersnapper.h" 18 | #include "hardware.h" 19 | 20 | class Wippersnapper; ///< Forward declaration 21 | class DisplayHardware; ///< Forward declaration 22 | 23 | /**************************************************************************/ 24 | /*! 25 | @brief Routes messages using the display.proto API to the 26 | appropriate hardware and model classes, controls and tracks 27 | the state of displays. 28 | */ 29 | /**************************************************************************/ 30 | class DisplayController { 31 | public: 32 | DisplayController(); 33 | ~DisplayController(); 34 | bool Handle_Display_AddOrReplace( 35 | wippersnapper_display_v1_DisplayAddOrReplace *msgAdd); 36 | bool Handle_Display_Remove(wippersnapper_display_v1_DisplayRemove *msgRemove); 37 | bool Handle_Display_Write(wippersnapper_display_v1_DisplayWrite *msgWrite); 38 | void update(int32_t rssi, bool is_connected); 39 | 40 | private: 41 | DisplayHardware *findDisplay(const char *name); 42 | std::vector 43 | _hw_instances; ///< Holds pointers to DisplayHardware instances 44 | unsigned long _last_bar_update; ///< Timestamp of last status bar update 45 | }; 46 | extern Wippersnapper WS; ///< Global WS instance 47 | #endif -------------------------------------------------------------------------------- /src/nanopb/pb_common.h: -------------------------------------------------------------------------------- 1 | /* pb_common.h: Common support functions for pb_encode.c and pb_decode.c. 2 | * These functions are rarely needed by applications directly. 3 | */ 4 | 5 | #ifndef PB_COMMON_H_INCLUDED 6 | #define PB_COMMON_H_INCLUDED 7 | 8 | #include "pb.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /* Initialize the field iterator structure to beginning. 15 | * Returns false if the message type is empty. */ 16 | bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_msgdesc_t *desc, void *message); 17 | 18 | /* Get a field iterator for extension field. */ 19 | bool pb_field_iter_begin_extension(pb_field_iter_t *iter, pb_extension_t *extension); 20 | 21 | /* Same as pb_field_iter_begin(), but for const message pointer. 22 | * Note that the pointers in pb_field_iter_t will be non-const but shouldn't 23 | * be written to when using these functions. */ 24 | bool pb_field_iter_begin_const(pb_field_iter_t *iter, const pb_msgdesc_t *desc, const void *message); 25 | bool pb_field_iter_begin_extension_const(pb_field_iter_t *iter, const pb_extension_t *extension); 26 | 27 | /* Advance the iterator to the next field. 28 | * Returns false when the iterator wraps back to the first field. */ 29 | bool pb_field_iter_next(pb_field_iter_t *iter); 30 | 31 | /* Advance the iterator until it points at a field with the given tag. 32 | * Returns false if no such field exists. */ 33 | bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag); 34 | 35 | /* Find a field with type PB_LTYPE_EXTENSION, or return false if not found. 36 | * There can be only one extension range field per message. */ 37 | bool pb_field_iter_find_extension(pb_field_iter_t *iter); 38 | 39 | #ifdef PB_VALIDATE_UTF8 40 | /* Validate UTF-8 text string */ 41 | bool pb_validate_utf8(const char *s); 42 | #endif 43 | 44 | #ifdef __cplusplus 45 | } /* extern "C" */ 46 | #endif 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /src/Wippersnapper_Networking.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Wippersnapper_Networking.h 3 | * 4 | * This file includes network interfaces at compile-time. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Brent Rubell 2020-2021 for Adafruit Industries. 11 | * 12 | * BSD license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | 16 | #ifndef WIPPERSNAPPER_NETWORKING_H 17 | #define WIPPERSNAPPER_NETWORKING_H 18 | 19 | #ifndef WL_MAC_ADDR_LENGTH 20 | #define WL_MAC_ADDR_LENGTH 6 ///< MAC address length - from RP2040 BSP 21 | #endif 22 | #define WS_MAX_ALT_WIFI_NETWORKS 3 ///< Maximum number of alternative networks 23 | 24 | #if defined(ADAFRUIT_METRO_M4_EXPRESS) || \ 25 | defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || defined(ADAFRUIT_PYPORTAL) || \ 26 | defined(ADAFRUIT_PYPORTAL_M4_TITANO) || defined(USE_AIRLIFT) || \ 27 | defined(ARDUINO_ADAFRUIT_FRUITJAM_RP2350) 28 | #include "network_interfaces/Wippersnapper_AIRLIFT.h" 29 | /** Nina-FW (adafruit fork) networking class */ 30 | typedef Wippersnapper_AIRLIFT Wippersnapper_WiFi; 31 | #elif defined(ARDUINO_ARCH_ESP8266) 32 | #include "network_interfaces/Wippersnapper_ESP8266.h" 33 | /** ESP8266's networking class */ 34 | typedef Wippersnapper_ESP8266 Wippersnapper_WiFi; 35 | #elif defined(ARDUINO_ARCH_ESP32) 36 | #include "network_interfaces/Wippersnapper_ESP32.h" 37 | /** ESP32's networking class */ 38 | typedef Wippersnapper_ESP32 Wippersnapper_WiFi; 39 | #elif defined(ARDUINO_ARCH_RP2040) 40 | #include "network_interfaces/ws_networking_pico.h" 41 | typedef ws_networking_pico Wippersnapper_WiFi; 42 | #else 43 | #warning "Must define network interface in config.h!" 44 | #endif 45 | 46 | #endif // WIPPERSNAPPER_NETWORKING_H -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit WipperSnapper 2 | version=1.0.0-beta.121 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Arduino application for Adafruit.io WipperSnapper 6 | paragraph=Arduino application for Adafruit.io WipperSnapper 7 | category=Communication 8 | url=https://github.com/adafruit/Adafruit_Wippersnapper_Arduino 9 | architectures=* 10 | depends=OmronD6T - Community Fork, SdFat - Adafruit Fork, Adafruit NeoPixel, Adafruit SPA06_003, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit HDC302x, Adafruit INA219, Adafruit INA260 Library, Adafruit INA237 and INA238 Library, Adafruit LTR329 and LTR303, Adafruit LTR390 Library, Adafruit MCP3421, Adafruit MLX90632 Library, Adafruit NAU7802 Library, Adafruit SleepyDog Library, Adafruit TMP117, Adafruit TinyUSB Library, Adafruit AHTX0, Adafruit AS5600 Library, Adafruit BME280 Library, Adafruit BMP280 Library, Adafruit BMP3XX Library, Adafruit BMP5xx Library, Adafruit DPS310, Adafruit DS248x, Adafruit SCD30, Adafruit SGP30 Sensor, Adafruit SGP40 Sensor, Sensirion I2C SCD4x, Sensirion I2C SEN5X, Sensirion I2C SEN66, arduino-sht, Adafruit Si7021 Library, Adafruit MQTT Library, Adafruit MS8607, Adafruit MCP9808 Library, Adafruit MCP9600 Library, Adafruit MPL115A2, Adafruit MPRLS Library, Adafruit TSL2591 Library, Adafruit_VL53L0X, Adafruit VL53L1X, STM32duino VL53L4CD, STM32duino VL53L4CX, Adafruit_VL6180X, Adafruit PM25 AQI Sensor, Adafruit QMC5883P Library, Adafruit VCNL4020 Library, Adafruit VCNL4040, Adafruit VCNL4200 Library, Adafruit VEML7700 Library, Adafruit LC709203F, Adafruit LPS2X, Adafruit LPS28, Adafruit LPS35HW, Adafruit seesaw Library, Adafruit BME680 Library, Adafruit MAX1704X, Adafruit ADT7410 Library, Adafruit HTS221, Adafruit HTU21DF Library, Adafruit HTU31D Library, Adafruit PCT2075, hp_BH1750, ENS160 - Adafruit Fork, Adafruit BusIO, Adafruit Unified Sensor, Sensirion Core, Adafruit GFX Library, Adafruit LED Backpack Library, Adafruit LiquidCrystal, Adafruit SH110X, Adafruit SSD1306, Adafruit EPD, Adafruit ST7735 and ST7789 Library 11 | -------------------------------------------------------------------------------- /src/wippersnapper/signal/v1/signal.pb.c: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.5-dev at Tue Sep 30 14:06:15 2025. */ 3 | 4 | #include "wippersnapper/signal/v1/signal.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(wippersnapper_signal_v1_UARTRequest, wippersnapper_signal_v1_UARTRequest, AUTO) 10 | 11 | 12 | PB_BIND(wippersnapper_signal_v1_UARTResponse, wippersnapper_signal_v1_UARTResponse, AUTO) 13 | 14 | 15 | PB_BIND(wippersnapper_signal_v1_Ds18x20Request, wippersnapper_signal_v1_Ds18x20Request, AUTO) 16 | 17 | 18 | PB_BIND(wippersnapper_signal_v1_Ds18x20Response, wippersnapper_signal_v1_Ds18x20Response, AUTO) 19 | 20 | 21 | PB_BIND(wippersnapper_signal_v1_I2CRequest, wippersnapper_signal_v1_I2CRequest, 2) 22 | 23 | 24 | PB_BIND(wippersnapper_signal_v1_I2CResponse, wippersnapper_signal_v1_I2CResponse, 2) 25 | 26 | 27 | PB_BIND(wippersnapper_signal_v1_ServoRequest, wippersnapper_signal_v1_ServoRequest, AUTO) 28 | 29 | 30 | PB_BIND(wippersnapper_signal_v1_ServoResponse, wippersnapper_signal_v1_ServoResponse, AUTO) 31 | 32 | 33 | PB_BIND(wippersnapper_signal_v1_PixelsRequest, wippersnapper_signal_v1_PixelsRequest, AUTO) 34 | 35 | 36 | PB_BIND(wippersnapper_signal_v1_PixelsResponse, wippersnapper_signal_v1_PixelsResponse, AUTO) 37 | 38 | 39 | PB_BIND(wippersnapper_signal_v1_CreateSignalRequest, wippersnapper_signal_v1_CreateSignalRequest, AUTO) 40 | 41 | 42 | PB_BIND(wippersnapper_signal_v1_SignalResponse, wippersnapper_signal_v1_SignalResponse, AUTO) 43 | 44 | 45 | PB_BIND(wippersnapper_signal_v1_PWMRequest, wippersnapper_signal_v1_PWMRequest, AUTO) 46 | 47 | 48 | PB_BIND(wippersnapper_signal_v1_PWMResponse, wippersnapper_signal_v1_PWMResponse, AUTO) 49 | 50 | 51 | PB_BIND(wippersnapper_signal_v1_DisplayRequest, wippersnapper_signal_v1_DisplayRequest, 2) 52 | 53 | 54 | PB_BIND(wippersnapper_signal_v1_DisplayResponse, wippersnapper_signal_v1_DisplayResponse, AUTO) 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/provisioning/tinyusb/Wippersnapper_FS.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Wippersnapper_FS.h 3 | * 4 | * Wippersnapper filesystem 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Brent Rubell 2021-2024 for Adafruit Industries. 11 | * 12 | * BSD license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef WIPPERSNAPPER_FS_H 16 | #define WIPPERSNAPPER_FS_H 17 | 18 | #include "Adafruit_SPIFlash.h" 19 | #include "Adafruit_TinyUSB.h" 20 | #include "SdFat_Adafruit_Fork.h" 21 | // using f_mkfs() for formatting 22 | #include "fatfs/ff.h" // NOTE: This should be #included before fatfs/diskio.h!!! 23 | #include "fatfs/diskio.h" 24 | 25 | #include "Wippersnapper.h" 26 | 27 | // forward decl. 28 | class Wippersnapper; 29 | 30 | // global TinyUSB callbacks 31 | int32_t qspi_msc_write_cb(uint32_t lba, uint8_t *buffer, uint32_t bufsize); 32 | int32_t qspi_msc_read_cb(uint32_t lba, void *buffer, uint32_t bufsize); 33 | void qspi_msc_flush_cb(void); 34 | 35 | /***************************************************************************/ 36 | /*! 37 | @brief Class that handles Wippersnapper's optional filesystem commands 38 | and storage. 39 | */ 40 | /***************************************************************************/ 41 | class Wippersnapper_FS { 42 | public: 43 | Wippersnapper_FS(); 44 | ~Wippersnapper_FS(); 45 | 46 | bool initFilesystem(bool force_format = false); 47 | void initUSBMSC(); 48 | 49 | void eraseCPFS(); 50 | void eraseBootFile(); 51 | 52 | bool configFileExists(); 53 | void createSecretsFile(); 54 | bool createBootFile(); 55 | void writeToBootOut(PGM_P str); 56 | void fsHalt(String msg); 57 | 58 | void parseSecrets(); 59 | private: 60 | bool _freshFS = false; /*!< True if filesystem was initialized by 61 | WipperSnapper, False otherwise. */ 62 | }; 63 | 64 | extern Wippersnapper WS; 65 | #endif // WIPPERSNAPPER_FS_H -------------------------------------------------------------------------------- /src/provisioning/ConfigJson.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file ConfigJson.cpp 3 | * 4 | * Wippersnapper JSON Config File Converters 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Brent Rubell 2024 for Adafruit Industries. 11 | * 12 | * BSD license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #include "ConfigJson.h" 16 | 17 | // Converts a network configuration structure to a JSON variant 18 | void convertToJson(const networkConfig &src, JsonVariant dst) { 19 | dst["network_ssid"] = src.ssid; 20 | dst["network_password"] = src.pass; 21 | } 22 | 23 | // Extracts a network configuration structure from a JSON variant 24 | void convertFromJson(JsonVariantConst src, networkConfig &dst) { 25 | strlcpy(dst.ssid, src["network_ssid"] | "unset-ssid", sizeof(dst.ssid)); 26 | strlcpy(dst.pass, src["network_password"] | "", sizeof(dst.pass)); 27 | } 28 | 29 | // Converts a secretsConfig structure to a JSON variant 30 | void convertToJson(const secretsConfig &src, JsonVariant dst) { 31 | dst["io_username"] = src.aio_user; 32 | dst["io_key"] = src.aio_key; 33 | dst["network_type_wifi"] = src.network; 34 | dst["status_pixel_brightness"] = src.status_pixel_brightness; 35 | } 36 | 37 | // Extracts a JSON file to a secretsConfig structure 38 | void convertFromJson(JsonVariantConst src, secretsConfig &dst) { 39 | // Parse network credentials from secrets 40 | dst.network = src["network_type_wifi"]; 41 | // Parse IO credentials from secrets 42 | strlcpy(dst.aio_user, src["io_username"] | "YOUR_IO_USERNAME_HERE", 43 | sizeof(dst.aio_user)); 44 | strlcpy(dst.aio_key, src["io_key"] | "YOUR_IO_KEY_HERE", sizeof(dst.aio_key)); 45 | strlcpy(dst.aio_url, src["io_url"] | "io.adafruit.com", sizeof(dst.aio_url)); 46 | // Parse status pixel brightness from secrets 47 | dst.status_pixel_brightness = src["status_pixel_brightness"] | 0.2; 48 | // Parse MQTT port from secrets, if exists 49 | dst.io_port = src["io_port"] | 8883; 50 | } -------------------------------------------------------------------------------- /src/components/ledc/ws_ledc.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file ws_ledc.h 3 | * 4 | * High-level interface for ESP32's LED Control (LEDC) peripheral, 5 | * to be used by PWM and Servo drivers. 6 | * 7 | * Adafruit invests time and resources providing this open source code, 8 | * please support Adafruit and open-source hardware by purchasing 9 | * products from Adafruit! 10 | * 11 | * Copyright (c) Brent Rubell 2022-2023 for Adafruit Industries. 12 | * 13 | * BSD license, all text here must be included in any redistribution. 14 | * 15 | */ 16 | #ifndef WS_LEDC_H 17 | #define WS_LEDC_H 18 | 19 | #include "Wippersnapper.h" 20 | 21 | #include "esp32-hal-ledc.h" 22 | #include "esp_err.h" 23 | 24 | // forward decl. 25 | class Wippersnapper; 26 | 27 | /**************************************************************************/ 28 | /*! 29 | @brief High-level interface for the ESP32/ESP32-Sx/ESP32-Cx LED 30 | Control (LEDC) peripheral. Instead of specifying a timer or 31 | channel, this class automatically allocates a channel and 32 | associates it with a pin. Underlying esp32-hal-ledc performs 33 | timer management and handles the low-level LEDC peripheral API 34 | calls. 35 | */ 36 | /**************************************************************************/ 37 | class ws_ledc { 38 | public: 39 | /**************************************************************************/ 40 | /*! 41 | @brief Ctor 42 | */ 43 | /**************************************************************************/ 44 | ws_ledc(){}; 45 | /**************************************************************************/ 46 | /*! 47 | @brief Dtor 48 | */ 49 | /**************************************************************************/ 50 | ~ws_ledc(){}; 51 | bool attachPin(uint8_t pin, uint32_t freq, uint8_t resolution); 52 | bool detachPin(uint8_t pin); 53 | // LEDC-API 54 | bool setDuty(uint8_t pin, uint32_t duty); 55 | bool analogWrite(uint8_t pin, int value); 56 | uint32_t tone(uint8_t pin, uint32_t freq); 57 | }; 58 | extern Wippersnapper WS; 59 | 60 | #endif // ws_ledc_H -------------------------------------------------------------------------------- /src/components/digitalIO/Wippersnapper_DigitalGPIO.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Wippersnapper_DigitalGPIO.h 3 | * 4 | * This file provides digital GPIO control and access. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Brent Rubell 2020-2021 for Adafruit Industries. 11 | * 12 | * BSD license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | 16 | #ifndef WIPPERSNAPPER_DIGITALGPIO_H 17 | #define WIPPERSNAPPER_DIGITALGPIO_H 18 | 19 | #include "Wippersnapper.h" 20 | 21 | /** Holds data about a digital input pin */ 22 | struct digitalInputPin { 23 | uint8_t pinName; ///< Pin name 24 | long period; ///< Timer interval, in millis, -1 if disabled. 25 | long prvPeriod; ///< When timer was previously serviced, in millis 26 | int prvPinVal; ///< Previous pin value 27 | }; 28 | 29 | // forward decl. 30 | class Wippersnapper; 31 | 32 | /**************************************************************************/ 33 | /*! 34 | @brief Class that provides functions for reading and interacting with 35 | digital inputs and outputs. 36 | */ 37 | /**************************************************************************/ 38 | class Wippersnapper_DigitalGPIO { 39 | public: 40 | Wippersnapper_DigitalGPIO(int32_t totalDigitalInputPins); 41 | ~Wippersnapper_DigitalGPIO(); 42 | 43 | void 44 | initDigitalPin(wippersnapper_pin_v1_ConfigurePinRequest_Direction direction, 45 | uint8_t pinName, float period, 46 | wippersnapper_pin_v1_ConfigurePinRequest_Pull pull); 47 | void 48 | deinitDigitalPin(wippersnapper_pin_v1_ConfigurePinRequest_Direction direction, 49 | uint8_t pinName); 50 | 51 | int digitalReadSvc(int pinName); 52 | void digitalWriteSvc(uint8_t pinName, int pinValue); 53 | void processDigitalInputs(); 54 | 55 | digitalInputPin *_digital_input_pins; /*!< Array of gpio pin objects */ 56 | private: 57 | int32_t 58 | _totalDigitalInputPins; /*!< Total number of digital-input capable pins */ 59 | }; 60 | extern Wippersnapper WS; 61 | 62 | #endif // WIPPERSNAPPER_DIGITALGPIO_H -------------------------------------------------------------------------------- /src/components/ds18x20/ws_ds18x20.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file ws_ds18x20.h 3 | * 4 | * This component implements 1-wire communication 5 | * for the DS18X20-line of Maxim Temperature ICs. 6 | * 7 | * Adafruit invests time and resources providing this open source code, 8 | * please support Adafruit and open-source hardware by purchasing 9 | * products from Adafruit! 10 | * 11 | * Copyright (c) Brent Rubell 2022 for Adafruit Industries. 12 | * 13 | * BSD license, all text here must be included in any redistribution. 14 | * 15 | */ 16 | #ifndef WIPPERSNAPPER_DS18X20_H 17 | #define WIPPERSNAPPER_DS18X20_H 18 | 19 | #include "Wippersnapper.h" 20 | 21 | #include 22 | #include 23 | 24 | /** DS18x20 Object */ 25 | struct ds18x20Obj { 26 | OneWire * 27 | oneWire; ///< Pointer to an OneWire bus used by a DallasTemperature object 28 | char onewire_pin[5]; ///< Pin utilized by the OneWire bus, used for addressing 29 | DallasTemperature 30 | *dallasTempObj; ///< Pointer to a DallasTemperature sensor object 31 | DeviceAddress dallasTempAddr; ///< Temperature sensor's address 32 | int sensorPropertiesCount; ///< Tracks # of sensorProperties 33 | wippersnapper_i2c_v1_I2CDeviceSensorProperties sensorProperties[2] = 34 | wippersnapper_i2c_v1_I2CDeviceSensorProperties_init_zero; ///< DS sensor 35 | ///< type(s) 36 | long sensorPeriodPrv; ///< Last time the sensor was polled, in millis 37 | }; 38 | 39 | // forward decl. 40 | class Wippersnapper; 41 | 42 | /**************************************************************************/ 43 | /*! 44 | @brief Class that provides an interface with DS18X20-compatible 45 | sensors. 46 | */ 47 | /**************************************************************************/ 48 | class ws_ds18x20 { 49 | public: 50 | ws_ds18x20(); 51 | ~ws_ds18x20(); 52 | 53 | bool 54 | addDS18x20(wippersnapper_ds18x20_v1_Ds18x20InitRequest *msgDs18x20InitReq); 55 | void deleteDS18x20( 56 | wippersnapper_ds18x20_v1_Ds18x20DeInitRequest *msgDS18x20DeinitReq); 57 | void update(); 58 | 59 | private: 60 | std::vector 61 | _ds18xDrivers; ///< Vec. of ptrs. to ds18x driver objects 62 | }; 63 | extern Wippersnapper WS; 64 | 65 | #endif // WIPPERSNAPPER_DS18X20_H -------------------------------------------------------------------------------- /src/nanopb/ws_pb_helpers.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file ws_pb_helpers.cpp 3 | * 4 | * Protobuf encode/decode helpers with error logging for Wippersnapper. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Tyeth Gundry 2024 for Adafruit Industries. 11 | * 12 | * BSD license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | 16 | #include "ws_pb_helpers.h" 17 | #include "../Wippersnapper.h" 18 | 19 | // ***************************************************************************** 20 | /*! 21 | @brief Decodes a protobuf message from a stream and prints any error. 22 | @param stream 23 | The stream to decode from. 24 | @param fields 25 | The protobuf message fields. 26 | @param dest_struct 27 | The destination struct to decode into. 28 | @return True if decode was successful, false otherwise. 29 | !*/ 30 | // ***************************************************************************** 31 | bool ws_pb_decode(pb_istream_t *stream, const pb_msgdesc_t *fields, 32 | void *dest_struct) { 33 | bool status = pb_decode(stream, fields, dest_struct); 34 | if (!status) { 35 | WS_DEBUG_PRINT("Protobuf decode error: "); 36 | WS_DEBUG_PRINTLN(PB_GET_ERROR(stream)); 37 | } 38 | return status; 39 | } 40 | 41 | // ***************************************************************************** 42 | /*! 43 | @brief Encodes a protobuf message to a stream and prints any error. 44 | @param stream 45 | The stream to encode to. 46 | @param fields 47 | The protobuf message fields. 48 | @param src_struct 49 | The source struct to encode from. 50 | @return True if encode was successful, false otherwise. 51 | !*/ 52 | // ***************************************************************************** 53 | bool ws_pb_encode(pb_ostream_t *stream, const pb_msgdesc_t *fields, 54 | const void *src_struct) { 55 | bool status = pb_encode(stream, fields, src_struct); 56 | if (!status) { 57 | WS_DEBUG_PRINT("Protobuf encode error: "); 58 | WS_DEBUG_PRINTLN(PB_GET_ERROR(stream)); 59 | } 60 | return status; 61 | } -------------------------------------------------------------------------------- /src/components/servo/ws_servo.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file ws_servo.h 3 | * 4 | * High-level interface for wippersnapper to manage servo objects 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * 11 | * Brent Rubell for Adafruit Industries 2022 12 | * 13 | * 14 | * MIT license, all text here must be included in any redistribution. 15 | * 16 | */ 17 | #ifndef WS_SERVO 18 | #define WS_SERVO 19 | 20 | #include "Wippersnapper.h" 21 | 22 | #if defined(ARDUINO_ARCH_ESP32) 23 | #include "components/ledc/drivers/servo/ws_ledc_servo.h" 24 | #else 25 | #include 26 | #endif 27 | 28 | #ifdef ARDUINO_ARCH_RP2040 29 | #define MAX_SERVO_NUM \ 30 | 8 ///< Maximum number of servo objects for Pico, 31 | ///< https://arduino-pico.readthedocs.io/en/latest/servo.html 32 | #else 33 | #define MAX_SERVO_NUM 16 ///< Maximum number of servo objects 34 | #endif 35 | 36 | #define MIN_SERVO_PULSE_WIDTH 500 ///< Default min. servo pulse width of 500uS 37 | #define ERR_SERVO_ATTACH 255 ///< Error when attempting to attach servo 38 | 39 | #if defined(ARDUINO_ARCH_ESP32) 40 | class ws_ledc_servo; 41 | /** Servo object for ESP32-servo implementation */ 42 | struct servoComponent { 43 | ws_ledc_servo *servoObj = nullptr; ///< Servo object 44 | uint8_t pin = 0; ///< Servo's pin number 45 | }; 46 | #else 47 | /** Servo object for Generic servo implementation */ 48 | struct servoComponent { 49 | Servo *servoObj = nullptr; ///< Servo object 50 | uint8_t pin = 0; ///< Servo's pin number 51 | }; 52 | #endif 53 | 54 | class Wippersnapper; 55 | 56 | /**************************************************************************/ 57 | /*! 58 | @brief Interface for WipperSnapper servo control 59 | */ 60 | /**************************************************************************/ 61 | class ws_servo { 62 | public: 63 | ws_servo(){}; 64 | ~ws_servo(); 65 | bool servo_attach(int pin, int minPulseWidth, int maxPulseWidth, int freq); 66 | void servo_detach(int pin); 67 | void servo_write(int pin, int value); 68 | servoComponent *getServoComponent(uint8_t pin); 69 | 70 | private: 71 | servoComponent _servos[MAX_SERVO_NUM]; ///< Container of servo objects and 72 | ///< their associated pin #s 73 | }; 74 | extern Wippersnapper WS; 75 | 76 | #endif // WS_SERVO -------------------------------------------------------------------------------- /src/components/uart/ws_uart.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file ws_uart.h 3 | * 4 | * Base class that provides an interface between WipperSnapper's app 5 | * and the device's UART bus. 6 | * 7 | * Adafruit invests time and resources providing this open source code, 8 | * please support Adafruit and open-source hardware by purchasing 9 | * products from Adafruit! 10 | * 11 | * Copyright (c) Brent Rubell 2023 for Adafruit Industries. 12 | * 13 | * BSD license, all text here must be included in any redistribution. 14 | * 15 | */ 16 | #ifndef WS_UART_H 17 | #define WS_UART_H 18 | 19 | #include "Wippersnapper.h" 20 | #include "drivers/ws_uart_drv.h" 21 | #include "drivers/ws_uart_drv_pm25aqi.h" 22 | 23 | /**************************************************************************/ 24 | /*! 25 | @brief Class that provides an interface between WipperSnapper's app 26 | and the device's UART bus. 27 | */ 28 | /**************************************************************************/ 29 | class ws_uart { 30 | public: 31 | ws_uart(){}; 32 | ~ws_uart(void); 33 | 34 | void 35 | initUARTBus(wippersnapper_uart_v1_UARTDeviceAttachRequest 36 | *msgUARTRequest); ///< Initializes the UART bus, called once 37 | bool initUARTDevice(wippersnapper_uart_v1_UARTDeviceAttachRequest 38 | *msgUARTRequest); ///< Initializes a UART driver. 39 | bool isUARTBusInitialized(); ///< Returns true if the UART bus is initialized 40 | void detachUARTDevice( 41 | wippersnapper_uart_v1_UARTDeviceDetachRequest 42 | *msgUARTDetachReq); ///< Detaches a UART device from the UART bus 43 | void deinitUARTDevice(const char *device_id); 44 | void update(); ///< Updates the UART device at every polling interval, must be 45 | ///< called by main app. 46 | #ifdef USE_SW_UART 47 | bool initUARTDevicePM25AQI(SoftwareSerial *swSerial, int32_t pollingInterval, 48 | const char *device_id); 49 | #else 50 | bool initUARTDevicePM25AQI(HardwareSerial *hwSerial, int32_t pollingInterval, 51 | const char *device_id); 52 | #endif 53 | private: 54 | #ifdef USE_SW_UART 55 | SoftwareSerial *_swSerial = nullptr; ///< SoftwareSerial instance 56 | #else 57 | HardwareSerial *_hwSerial = nullptr; ///< HardwareSerial instance 58 | #endif 59 | bool _is_bus_initialized = false; ///< True if UART bus is initialized 60 | std::vector uartDrivers; ///< Vector of UART drivers 61 | ws_uart_drv_pm25aqi *_pm25aqi = nullptr; ///< Pointer to a PM25 AQI device 62 | }; 63 | 64 | #endif // WS_UART_H -------------------------------------------------------------------------------- /src/components/display/hardware.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file src/components/display/hardware.h 3 | * 4 | * Hardware interface for display components. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Brent Rubell 2025 for Adafruit Industries. 11 | * 12 | * BSD license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef WS_DISPLAY_HARDWARE_H 16 | #define WS_DISPLAY_HARDWARE_H 17 | #include "Wippersnapper.h" 18 | #include "drivers/dispDrvBase.h" 19 | #include "drivers/dispDrvSt7789.h" 20 | #include "drivers/dispDrvThinkInkGrayscale4Eaamfgn.h" 21 | #include "drivers/dispDrvThinkInkGrayscale4T5.h" 22 | #include 23 | #include 24 | 25 | /*! 26 | @brief Interface for interacting with display hardware (TFT, eInk, 27 | OLED, etc.) 28 | This class provides methods to initialize, write to, and 29 | manage the state of display hardware. 30 | */ 31 | class DisplayHardware { 32 | public: 33 | DisplayHardware(const char *name); 34 | ~DisplayHardware(); 35 | 36 | // 37 | // API for configuring the display hardware // 38 | // 39 | const char *getName(); 40 | void setType(wippersnapper_display_v1_DisplayType type); 41 | wippersnapper_display_v1_DisplayType getType(); 42 | bool beginEPD(wippersnapper_display_v1_DisplayDriver *driver, 43 | wippersnapper_display_v1_EPDConfig *config, 44 | wippersnapper_display_v1_EpdSpiConfig *spi_config); 45 | bool beginTft(wippersnapper_display_v1_DisplayDriver *driver, 46 | wippersnapper_display_v1_TftConfig *config, 47 | wippersnapper_display_v1_TftSpiConfig *spi_config); 48 | 49 | void showSplash(); 50 | void drawStatusBar(const char *io_username); 51 | void updateStatusBar(int8_t rssi, uint8_t bat, bool mqtt_connected); 52 | // 53 | // API for Adafruit_GFX that abstracts hardware functionality 54 | // NOTE: These methods are meant to be implemented within dispDrvBase and 55 | // exposed within dispDrv driver instances 56 | // 57 | void writeMessage(const char *message); 58 | 59 | private: 60 | int16_t parsePin(const char *pinStr); 61 | void removeSuffix(const char *suffix); 62 | bool detect_ssd1680(uint8_t cs, uint8_t dc, uint8_t rst); 63 | char _name[64]; ///< Identifies the hardware instance 64 | wippersnapper_display_v1_DisplayType _type; ///< Display type 65 | dispDrvBase *_drvDisp = nullptr; ///< Base display driver 66 | }; 67 | #endif // WS_DISPLAY_HARDWARE_H -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | # Adafruit WipperSnapper 6 | ![Build CI](https://github.com/adafruit/Adafruit_Wippersnapper_Arduino/actions/workflows/build-clang-doxy.yml/badge.svg)[![Documentation](https://github.com/adafruit/ci-arduino/blob/master/assets/doxygen_badge.svg)](http://adafruit.github.io/Adafruit_Wippersnapper_Arduino/html/index.html) 7 | 8 | Adafruit.io WipperSnapper is a firmware designed to turn any Wi-Fi-capable board into an Internet-of-Things (IoT) device. No programming is required! 9 | 10 | WipperSnapper works with multiple microcontroller architectures such as ESP8266, ESP32, ESP32-Sx, ESP32-Cx, RP2040, RP2350, and ATSAMD51. 11 | 12 | You will need a **free** [Adafruit IO](https://io.adafruit.com) account to use WipperSnapper. 13 | 14 | **NOTE: WipperSnapper firmware is in beta** and is actively being developed. Please [report bugs via the issues page on this repository](https://github.com/adafruit/Adafruit_Wippersnapper_Arduino/issues/new?assignees=&labels=&projects=&template=bug_report.md&title=). 15 | 16 | # Get Started 17 | [Learn how to install and use WipperSnapper by following this guide on the Adafruit Learning System - QuickStart: Adafruit IO WipperSnapper](https://learn.adafruit.com/quickstart-adafruit-io-wippersnapper). 18 | 19 | ## Supported Platforms 20 | 21 | |Platform| MCU(s) | 22 | |--|--| 23 | |[ESP32-x](https://github.com/espressif/arduino-esp32)| ESP32, ESP32-Sx, ESP32-C3, ESP32-C5, ESP32-C6 | 24 | |[ESP8266](https://github.com/esp8266/Arduino)| ESP8266 | 25 | |[RP2040](https://github.com/earlephilhower/arduino-pico)| RP2040 MCU w/WiFi (i.e: Pico W) | 26 | |[RP2350](https://github.com/earlephilhower/arduino-pico)| RP2350 MCU w/WiFi (i.e: Pico 2W) | 27 | |[ATSAMD](https://github.com/adafruit/ArduinoCore-samd/)| SAMD51 MCU w/separate WiFi Co-Processor (i.e: Adafruit "AirLift")| 28 | 29 | ## Contributing to Adafruit.io and WipperSnapper 30 | 31 | If you have a sensor, input, or output you'd like to add Adafruit IO support for it - [we have a guide for contributing a new sensor to Adafruit.io and WipperSnapper here](https://learn.adafruit.com/how-to-add-a-new-component-to-adafruit-io-wippersnapper). 32 | 33 | If you have a WiFi-enabled development board with a compatible microcontroller (see: "Supported Hardware" section above) and would like to add Adafruit IO support for it - [we have a guide for adding a new board to Adafruit.io and WipperSnapper here](https://learn.adafruit.com/how-to-add-a-new-board-to-wippersnapper). 34 | 35 | ## Building WipperSnapper 36 | 37 | - (Preferred Method) [Build WipperSnapper with PlatformIO](https://learn.adafruit.com/how-to-add-a-new-component-to-adafruit-io-wippersnapper/build-wippersnapper-with-platformio) 38 | - Build WipperSnapper with Arduino 39 | -------------------------------------------------------------------------------- /src/wippersnapper/i2c/v1/i2c.pb.c: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb constant definitions */ 2 | /* Generated by nanopb-0.4.5-dev at Tue Sep 30 14:06:15 2025. */ 3 | 4 | #include "wippersnapper/i2c/v1/i2c.pb.h" 5 | #if PB_PROTO_HEADER_VERSION != 40 6 | #error Regenerate this file with the current version of nanopb generator. 7 | #endif 8 | 9 | PB_BIND(wippersnapper_i2c_v1_I2CBusInitRequest, wippersnapper_i2c_v1_I2CBusInitRequest, AUTO) 10 | 11 | 12 | PB_BIND(wippersnapper_i2c_v1_I2CBusInitResponse, wippersnapper_i2c_v1_I2CBusInitResponse, AUTO) 13 | 14 | 15 | PB_BIND(wippersnapper_i2c_v1_I2CBusSetFrequency, wippersnapper_i2c_v1_I2CBusSetFrequency, AUTO) 16 | 17 | 18 | PB_BIND(wippersnapper_i2c_v1_I2CBusScanRequest, wippersnapper_i2c_v1_I2CBusScanRequest, AUTO) 19 | 20 | 21 | PB_BIND(wippersnapper_i2c_v1_I2CBusScanResponse, wippersnapper_i2c_v1_I2CBusScanResponse, 2) 22 | 23 | 24 | PB_BIND(wippersnapper_i2c_v1_I2CDeviceSensorProperties, wippersnapper_i2c_v1_I2CDeviceSensorProperties, AUTO) 25 | 26 | 27 | PB_BIND(wippersnapper_i2c_v1_I2CDeviceInitRequests, wippersnapper_i2c_v1_I2CDeviceInitRequests, AUTO) 28 | 29 | 30 | PB_BIND(wippersnapper_i2c_v1_I2CDeviceInitRequest, wippersnapper_i2c_v1_I2CDeviceInitRequest, 2) 31 | 32 | 33 | PB_BIND(wippersnapper_i2c_v1_I2CDeviceInitResponse, wippersnapper_i2c_v1_I2CDeviceInitResponse, AUTO) 34 | 35 | 36 | PB_BIND(wippersnapper_i2c_v1_I2CDeviceUpdateRequest, wippersnapper_i2c_v1_I2CDeviceUpdateRequest, 2) 37 | 38 | 39 | PB_BIND(wippersnapper_i2c_v1_I2CDeviceUpdateResponse, wippersnapper_i2c_v1_I2CDeviceUpdateResponse, AUTO) 40 | 41 | 42 | PB_BIND(wippersnapper_i2c_v1_I2CDeviceDeinitRequest, wippersnapper_i2c_v1_I2CDeviceDeinitRequest, AUTO) 43 | 44 | 45 | PB_BIND(wippersnapper_i2c_v1_I2CDeviceDeinitResponse, wippersnapper_i2c_v1_I2CDeviceDeinitResponse, AUTO) 46 | 47 | 48 | PB_BIND(wippersnapper_i2c_v1_SensorEvent, wippersnapper_i2c_v1_SensorEvent, AUTO) 49 | 50 | 51 | PB_BIND(wippersnapper_i2c_v1_I2CDeviceEvent, wippersnapper_i2c_v1_I2CDeviceEvent, AUTO) 52 | 53 | 54 | PB_BIND(wippersnapper_i2c_v1_I2CDeviceOutputWrite, wippersnapper_i2c_v1_I2CDeviceOutputWrite, 2) 55 | 56 | 57 | PB_BIND(wippersnapper_i2c_v1_LEDBackpackConfig, wippersnapper_i2c_v1_LEDBackpackConfig, AUTO) 58 | 59 | 60 | PB_BIND(wippersnapper_i2c_v1_CharLCDConfig, wippersnapper_i2c_v1_CharLCDConfig, AUTO) 61 | 62 | 63 | PB_BIND(wippersnapper_i2c_v1_SSD1306Config, wippersnapper_i2c_v1_SSD1306Config, AUTO) 64 | 65 | 66 | PB_BIND(wippersnapper_i2c_v1_I2COutputAdd, wippersnapper_i2c_v1_I2COutputAdd, AUTO) 67 | 68 | 69 | PB_BIND(wippersnapper_i2c_v1_LEDBackpackWrite, wippersnapper_i2c_v1_LEDBackpackWrite, AUTO) 70 | 71 | 72 | PB_BIND(wippersnapper_i2c_v1_CharLCDWrite, wippersnapper_i2c_v1_CharLCDWrite, AUTO) 73 | 74 | 75 | PB_BIND(wippersnapper_i2c_v1_SSD1306Write, wippersnapper_i2c_v1_SSD1306Write, 2) 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /src/components/pixels/ws_pixels.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file ws_pixels.h 3 | * 4 | * High-level interface for wippersnapper to manage addressable RGB pixel 5 | * strands 6 | * 7 | * Adafruit invests time and resources providing this open source code, 8 | * please support Adafruit and open-source hardware by purchasing 9 | * products from Adafruit! 10 | * 11 | * 12 | * Brent Rubell for Adafruit Industries, 2022-2023 13 | * 14 | * 15 | * MIT license, all text here must be included in any redistribution. 16 | * 17 | */ 18 | #ifndef WS_PIXELS 19 | #define WS_PIXELS 20 | 21 | #include "Wippersnapper.h" 22 | 23 | #define MAX_PIXEL_STRANDS \ 24 | 5 ///< Maximum number of pixel strands connected to a WipperSnapper device 25 | 26 | #define ERR_INVALID_STRAND -1 ///< Invalid strand index 27 | 28 | /** Object representation of a strand of pixels */ 29 | struct strand_s { 30 | Adafruit_NeoPixel *neoPixelPtr; ///< Ptr to a NeoPixel object 31 | Adafruit_DotStar *dotStarPtr; ///< Ptr to a DotStar object 32 | wippersnapper_pixels_v1_PixelsType 33 | type; ///< Type of strand (DotStar, NeoPixel) 34 | uint8_t brightness; ///< Strand brightness (0 to 255) 35 | uint16_t numPixels; ///< Number of pixels on strand 36 | wippersnapper_pixels_v1_PixelsOrder ordering; ///< Color order of strand 37 | int16_t pinNeoPixel; ///< NeoPixel strand data pin 38 | int16_t pinDotStarData; ///< DotStar strand data pin 39 | int16_t pinDotStarClock; ///< DotStar strand clock pin 40 | }; 41 | 42 | class Wippersnapper; ///< friend class 43 | /**************************************************************************/ 44 | /*! 45 | @brief Class for managing and interfacing with strands of addressable 46 | RGB LED pixels. 47 | */ 48 | /**************************************************************************/ 49 | class ws_pixels { 50 | public: 51 | ws_pixels(); 52 | ~ws_pixels(); 53 | 54 | // Protobuf RPC 55 | bool 56 | addStrand(wippersnapper_pixels_v1_PixelsCreateRequest *pixelsCreateReqMsg); 57 | void 58 | deleteStrand(wippersnapper_pixels_v1_PixelsDeleteRequest *pixelsDeleteMsg); 59 | void fillStrand(wippersnapper_pixels_v1_PixelsWriteRequest *pixelsWriteMsg); 60 | 61 | // Helpers 62 | int16_t allocateStrand(); 63 | void deallocateStrand(int16_t strandIdx); 64 | int getStrandIdx(int16_t pin, wippersnapper_pixels_v1_PixelsType type); 65 | neoPixelType 66 | getNeoPixelStrandOrder(wippersnapper_pixels_v1_PixelsOrder pixelOrder); 67 | uint8_t getDotStarStrandOrder(wippersnapper_pixels_v1_PixelsOrder pixelOrder); 68 | void publishAddStrandResponse(bool is_success, char *pixels_pin_data); 69 | uint32_t getGammaCorrectedColor(uint32_t pixel_color, strand_s strand); 70 | }; 71 | extern Wippersnapper WS; 72 | #endif // WS_PIXELS -------------------------------------------------------------------------------- /src/provisioning/tinyusb/fatfs/diskio.h: -------------------------------------------------------------------------------- 1 | /*-----------------------------------------------------------------------/ 2 | / Low level disk interface modlue include file (C)ChaN, 2014 / 3 | /-----------------------------------------------------------------------*/ 4 | 5 | #ifndef _DISKIO_DEFINED 6 | #define _DISKIO_DEFINED 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | /* Status of Disk Functions */ 13 | typedef BYTE DSTATUS; 14 | 15 | /* Results of Disk Functions */ 16 | typedef enum { 17 | RES_OK = 0, /* 0: Successful */ 18 | RES_ERROR, /* 1: R/W Error */ 19 | RES_WRPRT, /* 2: Write Protected */ 20 | RES_NOTRDY, /* 3: Not Ready */ 21 | RES_PARERR /* 4: Invalid Parameter */ 22 | } DRESULT; 23 | 24 | 25 | /*---------------------------------------*/ 26 | /* Prototypes for disk control functions */ 27 | 28 | 29 | DSTATUS disk_initialize (BYTE pdrv); 30 | DSTATUS disk_status (BYTE pdrv); 31 | DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); 32 | DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); 33 | DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); 34 | 35 | 36 | /* Disk Status Bits (DSTATUS) */ 37 | 38 | #define STA_NOINIT 0x01 /* Drive not initialized */ 39 | #define STA_NODISK 0x02 /* No medium in the drive */ 40 | #define STA_PROTECT 0x04 /* Write protected */ 41 | 42 | 43 | /* Command code for disk_ioctrl fucntion */ 44 | 45 | /* Generic command (Used by FatFs) */ 46 | #define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */ 47 | #define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */ 48 | #define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */ 49 | #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */ 50 | #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */ 51 | 52 | /* Generic command (Not used by FatFs) */ 53 | #define CTRL_POWER 5 /* Get/Set power status */ 54 | #define CTRL_LOCK 6 /* Lock/Unlock media removal */ 55 | #define CTRL_EJECT 7 /* Eject media */ 56 | #define CTRL_FORMAT 8 /* Create physical format on the media */ 57 | 58 | /* MMC/SDC specific ioctl command */ 59 | #define MMC_GET_TYPE 10 /* Get card type */ 60 | #define MMC_GET_CSD 11 /* Get CSD */ 61 | #define MMC_GET_CID 12 /* Get CID */ 62 | #define MMC_GET_OCR 13 /* Get OCR */ 63 | #define MMC_GET_SDSTAT 14 /* Get SD status */ 64 | #define ISDIO_READ 55 /* Read data form SD iSDIO register */ 65 | #define ISDIO_WRITE 56 /* Write data to SD iSDIO register */ 66 | #define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */ 67 | 68 | /* ATA/CF specific ioctl command */ 69 | #define ATA_GET_REV 20 /* Get F/W revision */ 70 | #define ATA_GET_MODEL 21 /* Get model name */ 71 | #define ATA_GET_SN 22 /* Get serial number */ 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /src/components/ledc/drivers/servo/ws_ledc_servo.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file ws_ledc_servo.h 3 | * 4 | * Driver for ESP32 servo control using the WipperSnapper 5 | * LEDC peripheral manager API. 6 | * 7 | * Adafruit invests time and resources providing this open source code, 8 | * please support Adafruit and open-source hardware by purchasing 9 | * products from Adafruit! 10 | * 11 | * 12 | * Brent Rubell for Adafruit Industries 2022 13 | * 14 | * 15 | * MIT license, all text here must be included in any redistribution. 16 | * 17 | */ 18 | #ifndef WS_ESP32_SERVO 19 | #define WS_ESP32_SERVO 20 | 21 | #include "components/ledc/ws_ledc.h" 22 | 23 | // from https://github.com/arduino-libraries/Servo/blob/master/src/Servo.h 24 | #define MIN_PULSE_WIDTH 544 ///< The shortest pulse sent to a servo 25 | #define MAX_PULSE_WIDTH 2400 ///< The longest pulse sent to a servo 26 | #define INVALID_SERVO 255 ///< Flag indicating an invalid servo index 27 | 28 | #define DEFAULT_SERVO_FREQ 50 ///< default servo frequency 29 | #define LEDC_TIMER_WIDTH \ 30 | 12 ///< timer width to request from LEDC manager component, in bits (NOTE: 31 | ///< While ESP32x can go up to 16 bit timer width, ESP32-S2 does not work 32 | ///< at this resolution. So, for the purposes of keeping this library 33 | ///< compatible with multiple ESP32x platforms, the timer width has been 34 | ///< scaled down to 10 bits and the calculation adjusted accordingly) 35 | 36 | /** Defines a servo attached to a pin */ 37 | typedef struct { 38 | uint8_t nbr; ///< Servo's pin number 39 | uint8_t isActive; ///< True if the servo is enabled 40 | } ServoPin_t; 41 | 42 | /** Defines a ws_ledc_servo object */ 43 | typedef struct { 44 | ServoPin_t Pin; ///< Servo properties 45 | } servo_t; 46 | 47 | class ws_ledc; 48 | 49 | /************************************************************************************************/ 50 | /*! 51 | @brief High-level driver for servos for ESP32/ESP32-Sx/ESP32-Cx. This 52 | driver implements a subset of the functions within the Arduino 53 | servo library, 54 | (https://github.com/arduino-libraries/Servo/blob/master/src/Servo.h). 55 | */ 56 | /************************************************************************************************/ 57 | class ws_ledc_servo { 58 | public: 59 | ws_ledc_servo(); 60 | ~ws_ledc_servo(); 61 | void setLEDCDriver(ws_ledc *ledcManager); 62 | // The functions below are compatible with 63 | // https://github.com/arduino-libraries/Servo/blob/master/src/Servo.h 64 | uint8_t attach(int pin, int minPulseWidth, int maxPulseWidth, int servoFreq); 65 | bool attached(); 66 | void detach(); 67 | void writeMicroseconds(int value); 68 | 69 | private: 70 | servo_t _servo; ///< ws_ledc_servo object 71 | int _minPulseWidth; ///< Servo's minimum pulse width, in uS. 72 | int _maxPulseWidth; ///< Servo's maximum pulse width, in uS. 73 | ws_ledc *_ledcMgr; 74 | }; 75 | #endif // WS_ESP32_SERVO -------------------------------------------------------------------------------- /src/components/display/assets/icons.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file src/components/display/assets/icons.h 3 | * 4 | * Icon assets for displays. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Brent Rubell 2025 for Adafruit Industries. 11 | * 12 | * BSD license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef _ICONS_H_ 16 | #define _ICONS_H_ 17 | #include 18 | 19 | /** 20 | * @brief cloud-thin-full icon from FontAwesome (16x16px) 21 | */ 22 | const unsigned char epd_bmp_cloud_online[] = { 23 | 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x0d, 0xc0, 0x18, 0x78, 0x10, 24 | 0x0c, 0x30, 0x04, 0x70, 0x0c, 0xc0, 0x06, 0xc0, 0x03, 0xc0, 0x03, 25 | 0x40, 0x03, 0x70, 0x06, 0x3f, 0xfc, 0x00, 0x00, 0x00, 0x00}; 26 | 27 | /** 28 | * @brief cloud-xmark-thin-full icon from FontAwesome (16x16px) 29 | */ 30 | const unsigned char epd_bmp_cloud_offline[] PROGMEM = { 31 | 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x0d, 0xc0, 0x18, 0x78, 0x10, 32 | 0x0c, 0x30, 0x04, 0x73, 0xcc, 0xe3, 0x86, 0xc3, 0xc3, 0xc3, 0xc3, 33 | 0x40, 0x03, 0x70, 0x06, 0x3f, 0xfc, 0x00, 0x00, 0x00, 0x00}; 34 | 35 | /** 36 | * @brief wifi-thin-full icon from FontAwesome (16x16px) 37 | */ 38 | const unsigned char epd_bmp_wifi_full[] = { 39 | 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x3c, 0x3c, 0x70, 0x0e, 0xc0, 40 | 0x03, 0x03, 0xc0, 0x0f, 0xf0, 0x1c, 0x38, 0x18, 0x18, 0x00, 0x00, 41 | 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00}; 42 | 43 | /** 44 | * @brief wifi-fair-thin-full icon from FontAwesome (16x16px) 45 | */ 46 | const unsigned char epd_bmp_wifi_fair[] = { 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 48 | 0x00, 0x03, 0xc0, 0x0f, 0xf0, 0x1c, 0x38, 0x18, 0x18, 0x00, 0x00, 49 | 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00}; 50 | 51 | /** 52 | * @brief wifi-weak-thin-full icon from FontAwesome (16x16px) 53 | */ 54 | const unsigned char epd_bmp_wifi_weak[] = { 55 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 56 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 57 | 0x03, 0xc0, 0x03, 0xc0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00}; 58 | 59 | /** 60 | * @brief wifi-slash-thin-full icon from FontAwesome (16x16px) 61 | */ 62 | const unsigned char epd_bmp_wifi_no_signal[] = { 63 | 0x00, 0x00, 0x40, 0x00, 0x27, 0xc0, 0x1e, 0x38, 0x68, 0x00, 0x44, 64 | 0x03, 0x03, 0x00, 0x01, 0xe0, 0x08, 0x90, 0x00, 0x40, 0x00, 0x20, 65 | 0x01, 0x90, 0x03, 0x88, 0x01, 0x84, 0x00, 0x02, 0x00, 0x00}; 66 | 67 | /** 68 | * @brief battery-full-thin-full icon from FontAwesome (16x16px) 69 | */ 70 | const unsigned char epd_bmp_bat_full[] = { 71 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfe, 0xc0, 0x06, 0xff, 72 | 0xfa, 0xf0, 0x0b, 0xf0, 0x0b, 0xf0, 0x0b, 0xf0, 0x0b, 0xff, 0xfa, 73 | 0xc0, 0x06, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 74 | 75 | #endif // _ICONS_H_ -------------------------------------------------------------------------------- /src/components/statusLED/Wippersnapper_StatusLED.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Wippersnapper_StatusLED.h 3 | * 4 | * Interfaces for the Wippersnapper status indicator LED/NeoPixel/Dotstar/RGB 5 | * LED. 6 | * 7 | * Adafruit invests time and resources providing this open source code, 8 | * please support Adafruit and open-source hardware by purchasing 9 | * products from Adafruit! 10 | * 11 | * Copyright (c) Brent Rubell 2022 for Adafruit Industries. 12 | * 13 | * BSD license, all text here must be included in any redistribution. 14 | * 15 | */ 16 | #ifndef WIPPERSNAPPER_STATUSLED_H 17 | #define WIPPERSNAPPER_STATUSLED_H 18 | #include 19 | #include 20 | 21 | // Use LEDC for ESP32 arch so we can PWM 22 | #ifdef ARDUINO_ARCH_ESP32 23 | #define LEDC_CHANNEL_0 \ 24 | 0 ///< use first channel of 16 channels (started from zero) 25 | #define LEDC_TIMER_12_BIT 12 ///< use 12 bit precision for LEDC timer 26 | #define LEDC_BASE_FREQ 5000 ///< use 5000Hz as a LEDC base frequency 27 | #endif 28 | 29 | #define STATUS_LED_KAT_BLINK_TIME \ 30 | 120000 ///< How often to blink the status LED while run() executes, if not 31 | ///< in-use 32 | 33 | /** Defines the Wippersnapper status LED states */ 34 | typedef enum ws_led_status_t { 35 | WS_LED_STATUS_FS_WRITE, 36 | WS_LED_STATUS_WIFI_CONNECTING, 37 | WS_LED_STATUS_MQTT_CONNECTING, 38 | WS_LED_STATUS_WAITING_FOR_REG_MSG, 39 | WS_LED_STATUS_ERROR_RUNTIME, 40 | WS_LED_STATUS_KAT, 41 | } ws_led_status_t; 42 | 43 | #define RED 0xFF0000 ///< Red (as a uint32) 44 | #define CYAN 0x00FFFF ///< Cyan (as a uint32) 45 | #define YELLOW 0xFFFF00 ///< Yellow (as a uint32) 46 | #define GREEN 0x00A300 ///< Green (as a uint32) 47 | #define BLACK 0x000000 ///< Black (as a uint32) 48 | #define PINK 0xFF00FF ///< Pink (as a uint32) 49 | #define BLUE 0x0000FF ///< Blue (as a uint32) 50 | #define AMBER 0xFFBF00 ///< Amber (as a uint32) 51 | 52 | // colors for each status state 53 | #define LED_NET_CONNECT PINK ///< Network connection state 54 | #define LED_IO_CONNECT BLUE ///< MQTT broker connection state 55 | #define LED_IO_REGISTER_HW YELLOW ///< Hardware registration state 56 | #define LED_CONNECTED GREEN ///< Successful registration state 57 | #define LED_ERROR RED ///< Error state 58 | 59 | #define STATUS_PIXEL_BRIGHTNESS_DEFAULT 0.5 ///< Default status pixel brightness 60 | #define STATUS_DOTSTAR_DEFAULT_COLOR_ORDER DOTSTAR_BGR ///< FunHouse default 61 | 62 | // Status LED 63 | void initStatusLED(); 64 | void releaseStatusLED(); 65 | int16_t getStatusNeoPixelPin(); 66 | int16_t getStatusDotStarDataPin(); 67 | uint32_t ledStatusStateToColor(ws_led_status_t statusState); 68 | void setStatusLEDBrightness(float brightness); 69 | void setStatusLEDColor(uint32_t color); 70 | void setStatusLEDColor(uint32_t color, int brightness); 71 | void statusLEDBlink(ws_led_status_t statusState = WS_LED_STATUS_ERROR_RUNTIME); 72 | void statusLEDFade(uint32_t color, int numFades); 73 | void statusLEDSolid(ws_led_status_t statusState); 74 | 75 | #endif // WIPPERSNAPPER_STATUSLED_H -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_TMP117.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_TMP117.h 3 | * 4 | * Device driver for the TMP117 Temperature sensor. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Tyeth Gundry 2023 for Adafruit Industries. 11 | * 12 | * MIT license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef WipperSnapper_I2C_Driver_TMP117_H 16 | #define WipperSnapper_I2C_Driver_TMP117_H 17 | 18 | #include "WipperSnapper_I2C_Driver.h" 19 | #include 20 | 21 | /**************************************************************************/ 22 | /*! 23 | @brief Class that provides a driver interface for a TMP117 sensor. 24 | */ 25 | /**************************************************************************/ 26 | class WipperSnapper_I2C_Driver_TMP117 : public WipperSnapper_I2C_Driver { 27 | public: 28 | /*******************************************************************************/ 29 | /*! 30 | @brief Constructor for a TMP117 sensor. 31 | @param i2c 32 | The I2C interface. 33 | @param sensorAddress 34 | 7-bit device address. 35 | */ 36 | /*******************************************************************************/ 37 | WipperSnapper_I2C_Driver_TMP117(TwoWire *i2c, uint16_t sensorAddress) 38 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 39 | _i2c = i2c; 40 | _sensorAddress = sensorAddress; 41 | } 42 | 43 | /*******************************************************************************/ 44 | /*! 45 | @brief Destructor for an TMP117 sensor. 46 | */ 47 | /*******************************************************************************/ 48 | ~WipperSnapper_I2C_Driver_TMP117() { 49 | // Called when a TMP117 component is deleted. 50 | delete _tmp117; 51 | } 52 | 53 | /*******************************************************************************/ 54 | /*! 55 | @brief Initializes the TMP117 sensor and begins I2C. 56 | @returns True if initialized successfully, False otherwise. 57 | */ 58 | /*******************************************************************************/ 59 | bool begin() { 60 | _tmp117 = new Adafruit_TMP117(); 61 | return _tmp117->begin((uint8_t)_sensorAddress, _i2c); 62 | } 63 | 64 | /*******************************************************************************/ 65 | /*! 66 | @brief Gets the TMP117's current temperature. 67 | @param tempEvent 68 | Pointer to an Adafruit_Sensor event. 69 | @returns True if the temperature was obtained successfully, False 70 | otherwise. 71 | */ 72 | /*******************************************************************************/ 73 | bool getEventAmbientTemp(sensors_event_t *tempEvent) { 74 | return _tmp117->getEvent(tempEvent); 75 | } 76 | 77 | protected: 78 | Adafruit_TMP117 *_tmp117; ///< Pointer to TMP117 temperature sensor object 79 | }; 80 | 81 | #endif // WipperSnapper_I2C_Driver_TMP117 -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_ADT7410.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_ADT7410.h 3 | * 4 | * Device driver for the ADT7410 Temperature sensor. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Brent Rubell 2023 for Adafruit Industries. 11 | * 12 | * MIT license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef WipperSnapper_I2C_Driver_ADT7410_H 16 | #define WipperSnapper_I2C_Driver_ADT7410_H 17 | 18 | #include "WipperSnapper_I2C_Driver.h" 19 | #include 20 | 21 | /**************************************************************************/ 22 | /*! 23 | @brief Class that provides a driver interface for a ADT7410 sensor. 24 | */ 25 | /**************************************************************************/ 26 | class WipperSnapper_I2C_Driver_ADT7410 : public WipperSnapper_I2C_Driver { 27 | public: 28 | /*******************************************************************************/ 29 | /*! 30 | @brief Constructor for a ADT7410 sensor. 31 | @param i2c 32 | The I2C interface. 33 | @param sensorAddress 34 | 7-bit device address. 35 | */ 36 | /*******************************************************************************/ 37 | WipperSnapper_I2C_Driver_ADT7410(TwoWire *i2c, uint16_t sensorAddress) 38 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 39 | _i2c = i2c; 40 | _sensorAddress = sensorAddress; 41 | } 42 | 43 | /*******************************************************************************/ 44 | /*! 45 | @brief Destructor for an ADT7410 sensor. 46 | */ 47 | /*******************************************************************************/ 48 | ~WipperSnapper_I2C_Driver_ADT7410() { 49 | // Called when a ADT7410 component is deleted. 50 | delete _ADT7410; 51 | } 52 | 53 | /*******************************************************************************/ 54 | /*! 55 | @brief Initializes the ADT7410 sensor and begins I2C. 56 | @returns True if initialized successfully, False otherwise. 57 | */ 58 | /*******************************************************************************/ 59 | bool begin() { 60 | _ADT7410 = new Adafruit_ADT7410(); 61 | return _ADT7410->begin((uint8_t)_sensorAddress, _i2c); 62 | } 63 | 64 | /*******************************************************************************/ 65 | /*! 66 | @brief Gets the ADT7410's current temperature. 67 | @param tempEvent 68 | Pointer to an Adafruit_Sensor event. 69 | @returns True if the temperature was obtained successfully, False 70 | otherwise. 71 | */ 72 | /*******************************************************************************/ 73 | bool getEventAmbientTemp(sensors_event_t *tempEvent) { 74 | tempEvent->temperature = _ADT7410->readTempC(); 75 | return true; 76 | } 77 | 78 | protected: 79 | Adafruit_ADT7410 *_ADT7410; ///< Pointer to ADT7410 temperature sensor object 80 | }; 81 | 82 | #endif // WipperSnapper_I2C_Driver_ADT7410 -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_MCP9808.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_MCP9808.h 3 | * 4 | * Device driver for the MCP9808 Temperature sensor. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Brent Rubell 2022 for Adafruit Industries. 11 | * 12 | * MIT license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef WipperSnapper_I2C_Driver_MCP9808_H 16 | #define WipperSnapper_I2C_Driver_MCP9808_H 17 | 18 | #include "WipperSnapper_I2C_Driver.h" 19 | #include 20 | 21 | /**************************************************************************/ 22 | /*! 23 | @brief Class that provides a driver interface for a MCP9808 sensor. 24 | */ 25 | /**************************************************************************/ 26 | class WipperSnapper_I2C_Driver_MCP9808 : public WipperSnapper_I2C_Driver { 27 | public: 28 | /*******************************************************************************/ 29 | /*! 30 | @brief Constructor for a MCP9808 sensor. 31 | @param i2c 32 | The I2C interface. 33 | @param sensorAddress 34 | 7-bit device address. 35 | */ 36 | /*******************************************************************************/ 37 | WipperSnapper_I2C_Driver_MCP9808(TwoWire *i2c, uint16_t sensorAddress) 38 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 39 | _i2c = i2c; 40 | _sensorAddress = sensorAddress; 41 | } 42 | 43 | /*******************************************************************************/ 44 | /*! 45 | @brief Destructor for an MCP9808 sensor. 46 | */ 47 | /*******************************************************************************/ 48 | ~WipperSnapper_I2C_Driver_MCP9808() { 49 | // Called when a MCP9808 component is deleted. 50 | delete _mcp9808; 51 | } 52 | 53 | /*******************************************************************************/ 54 | /*! 55 | @brief Initializes the MCP9808 sensor and begins I2C. 56 | @returns True if initialized successfully, False otherwise. 57 | */ 58 | /*******************************************************************************/ 59 | bool begin() { 60 | _mcp9808 = new Adafruit_MCP9808(); 61 | return _mcp9808->begin((uint8_t)_sensorAddress, _i2c); 62 | } 63 | 64 | /*******************************************************************************/ 65 | /*! 66 | @brief Gets the MCP9808's current temperature. 67 | @param tempEvent 68 | Pointer to an Adafruit_Sensor event. 69 | @returns True if the temperature was obtained successfully, False 70 | otherwise. 71 | */ 72 | /*******************************************************************************/ 73 | bool getEventAmbientTemp(sensors_event_t *tempEvent) { 74 | tempEvent->temperature = _mcp9808->readTempC(); 75 | return true; 76 | } 77 | 78 | protected: 79 | Adafruit_MCP9808 *_mcp9808; ///< Pointer to MCP9808 temperature sensor object 80 | }; 81 | 82 | #endif // WipperSnapper_I2C_Driver_MCP9808 -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_PCT2075.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_PCT2075.h 3 | * 4 | * Device driver for the PCT2075 Temperature sensor. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Tyeth Gundry 2023 for Adafruit Industries. 11 | * 12 | * MIT license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef WipperSnapper_I2C_Driver_PCT2075_H 16 | #define WipperSnapper_I2C_Driver_PCT2075_H 17 | 18 | #include "WipperSnapper_I2C_Driver.h" 19 | #include 20 | 21 | /**************************************************************************/ 22 | /*! 23 | @brief Class that provides a driver interface for a PCT2075 sensor. 24 | */ 25 | /**************************************************************************/ 26 | class WipperSnapper_I2C_Driver_PCT2075 : public WipperSnapper_I2C_Driver { 27 | public: 28 | /*******************************************************************************/ 29 | /*! 30 | @brief Constructor for a PCT2075 sensor. 31 | @param i2c 32 | The I2C interface. 33 | @param sensorAddress 34 | 7-bit device address. 35 | */ 36 | /*******************************************************************************/ 37 | WipperSnapper_I2C_Driver_PCT2075(TwoWire *i2c, uint16_t sensorAddress) 38 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 39 | _i2c = i2c; 40 | _sensorAddress = sensorAddress; 41 | } 42 | 43 | /*******************************************************************************/ 44 | /*! 45 | @brief Destructor for an PCT2075 sensor. 46 | */ 47 | /*******************************************************************************/ 48 | ~WipperSnapper_I2C_Driver_PCT2075() { 49 | // Called when a PCT2075 component is deleted. 50 | delete _pct2075; 51 | } 52 | 53 | /*******************************************************************************/ 54 | /*! 55 | @brief Initializes the PCT2075 sensor and begins I2C. 56 | @returns True if initialized successfully, False otherwise. 57 | */ 58 | /*******************************************************************************/ 59 | bool begin() { 60 | _pct2075 = new Adafruit_PCT2075(); 61 | return _pct2075->begin((uint8_t)_sensorAddress, _i2c); 62 | } 63 | 64 | /*******************************************************************************/ 65 | /*! 66 | @brief Gets the PCT2075's current temperature. 67 | @param tempEvent 68 | Pointer to an Adafruit_Sensor event. 69 | @returns True if the temperature was obtained successfully, False 70 | otherwise. 71 | */ 72 | /*******************************************************************************/ 73 | bool getEventAmbientTemp(sensors_event_t *tempEvent) { 74 | tempEvent->temperature = _pct2075->getTemperature(); 75 | return true; 76 | } 77 | 78 | protected: 79 | Adafruit_PCT2075 *_pct2075; ///< Pointer to PCT2075 temperature sensor object 80 | }; 81 | 82 | #endif // WipperSnapper_I2C_Driver_PCT2075 -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_MPRLS.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_MPRLS.h 3 | * 4 | * Device driver for a MPRLS precision pressure sensor breakout. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Tyeth Gundry 2023 for Adafruit Industries. 11 | * 12 | * MIT license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | 16 | #ifndef WipperSnapper_I2C_Driver_MPRLS_H 17 | #define WipperSnapper_I2C_Driver_MPRLS_H 18 | 19 | #include "WipperSnapper_I2C_Driver.h" 20 | #include 21 | 22 | /**************************************************************************/ 23 | /*! 24 | @brief Class that provides a sensor driver for the MPRLS sensor. 25 | */ 26 | /**************************************************************************/ 27 | class WipperSnapper_I2C_Driver_MPRLS : public WipperSnapper_I2C_Driver { 28 | 29 | public: 30 | /*******************************************************************************/ 31 | /*! 32 | @brief Constructor for an MPRLS sensor. 33 | @param i2c 34 | The I2C interface. 35 | @param sensorAddress 36 | 7-bit device address. 37 | */ 38 | /*******************************************************************************/ 39 | WipperSnapper_I2C_Driver_MPRLS(TwoWire *i2c, uint16_t sensorAddress) 40 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 41 | _i2c = i2c; 42 | _sensorAddress = sensorAddress; 43 | } 44 | 45 | /*******************************************************************************/ 46 | /*! 47 | @brief Destructor for an MPRLS sensor. 48 | */ 49 | /*******************************************************************************/ 50 | ~WipperSnapper_I2C_Driver_MPRLS() { delete _mprls; } 51 | 52 | /*******************************************************************************/ 53 | /*! 54 | @brief Initializes the MPRLS sensor and begins I2C. 55 | @returns True if initialized successfully, False otherwise. 56 | */ 57 | /*******************************************************************************/ 58 | bool begin() { 59 | _mprls = new Adafruit_MPRLS(); 60 | // attempt to initialize MPRLS 61 | if (!_mprls->begin(_sensorAddress, _i2c)) 62 | return false; 63 | 64 | return true; 65 | } 66 | 67 | /*******************************************************************************/ 68 | /*! 69 | @brief Reads a pressure sensor and converts 70 | the reading into the expected SI unit. 71 | @param pressureEvent 72 | Pointer to an Adafruit_Sensor event. 73 | @returns True if the sensor event was obtained successfully, False 74 | otherwise. 75 | */ 76 | /*******************************************************************************/ 77 | bool getEventPressure(sensors_event_t *pressureEvent) { 78 | pressureEvent->pressure = _mprls->readPressure(); 79 | return pressureEvent->pressure != NAN; 80 | } 81 | 82 | protected: 83 | Adafruit_MPRLS *_mprls; ///< MPRLS object 84 | }; 85 | 86 | #endif // WipperSnapper_I2C_Driver_MPRLS -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_INA260.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_INA260.cpp 3 | * 4 | * Device driver implementation for the INA260 DC Current and Voltage Monitor 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Tyeth Gundry 2025 for Adafruit Industries. 11 | * 12 | * MIT license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | 16 | #include "WipperSnapper_I2C_Driver_INA260.h" 17 | #include "Wippersnapper.h" 18 | #include 19 | 20 | /*******************************************************************************/ 21 | /*! 22 | @brief Constructor for a INA260 sensor. 23 | @param i2c 24 | The I2C interface. 25 | @param sensorAddress 26 | The 7-bit I2C address of the sensor. 27 | */ 28 | /*******************************************************************************/ 29 | WipperSnapper_I2C_Driver_INA260::WipperSnapper_I2C_Driver_INA260( 30 | TwoWire *i2c, uint16_t sensorAddress) 31 | : WipperSnapper_I2C_Driver(i2c, sensorAddress), _ina260(nullptr) { 32 | _i2c = i2c; 33 | _sensorAddress = sensorAddress; 34 | } 35 | 36 | /*******************************************************************************/ 37 | /*! 38 | @brief Destructor for an INA260 sensor. 39 | */ 40 | /*******************************************************************************/ 41 | WipperSnapper_I2C_Driver_INA260::~WipperSnapper_I2C_Driver_INA260() { 42 | delete _ina260; 43 | } 44 | 45 | /*******************************************************************************/ 46 | /*! 47 | @brief Initializes the INA260 sensor and begins I2C. 48 | @returns True if initialized successfully, False otherwise. 49 | */ 50 | /*******************************************************************************/ 51 | bool WipperSnapper_I2C_Driver_INA260::begin() { 52 | _ina260 = new Adafruit_INA260(); 53 | if (!_ina260->begin(_sensorAddress, _i2c)) { 54 | return false; 55 | } 56 | // TODO: use setCalibration() 57 | 58 | return true; 59 | } 60 | 61 | /*******************************************************************************/ 62 | /*! 63 | @brief Reads a voltage sensor and converts the 64 | reading into the expected SI unit. 65 | @param voltageEvent 66 | voltage sensor reading, in volts. 67 | @returns True if the sensor event was obtained successfully, False 68 | otherwise. 69 | */ 70 | /*******************************************************************************/ 71 | bool WipperSnapper_I2C_Driver_INA260::getEventVoltage( 72 | sensors_event_t *voltageEvent) { 73 | voltageEvent->voltage = _ina260->readBusVoltage() / 1000.0f; 74 | return true; 75 | } 76 | 77 | /** 78 | * @brief Get the current sensor event. 79 | * 80 | * @param currentEvent Pointer to the current sensor event. 81 | * 82 | * @returns True if the sensor event was obtained successfully, False 83 | * otherwise. 84 | */ 85 | bool WipperSnapper_I2C_Driver_INA260::getEventCurrent( 86 | sensors_event_t *currentEvent) { 87 | currentEvent->current = _ina260->readCurrent(); 88 | return true; 89 | } -------------------------------------------------------------------------------- /src/components/analogIO/Wippersnapper_AnalogIO.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Wippersnapper_AnalogIO.h 3 | * 4 | * This file provides digital GPIO control and access. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Brent Rubell 2020-2023 for Adafruit Industries. 11 | * 12 | * BSD license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | 16 | #ifndef WIPPERSNAPPER_ANALOGIO_H 17 | #define WIPPERSNAPPER_ANALOGIO_H 18 | 19 | #include "Wippersnapper.h" 20 | 21 | #define DEFAULT_HYSTERISIS 0.02 ///< Default DEFAULT_HYSTERISIS of 2% 22 | 23 | /** Data about an analog input pin */ 24 | struct analogInputPin { 25 | int pinName; ///< Pin name 26 | bool enabled; ///< Pin is enabled for sampling 27 | wippersnapper_pin_v1_ConfigurePinRequest_AnalogReadMode 28 | readMode; ///< Which type of analog read to perform 29 | long period; ///< Pin timer interval, in millis, -1 if disabled. 30 | long prvPeriod; ///< When Pin's timer was previously serviced, in millis 31 | float prvPinVal; ///< Previous pin value 32 | }; 33 | 34 | // forward decl. 35 | class Wippersnapper; 36 | 37 | /**************************************************************************/ 38 | /*! 39 | @brief Class that provides an interface for reading and controlling 40 | analog pins. Stores information about analog input pins. 41 | */ 42 | /**************************************************************************/ 43 | class Wippersnapper_AnalogIO { 44 | public: 45 | Wippersnapper_AnalogIO(int32_t totalAnalogInputPins, float aRef); 46 | ~Wippersnapper_AnalogIO(); 47 | 48 | void setAref(float refVoltage); 49 | float getAref(); 50 | 51 | void initAnalogInputPin( 52 | int pin, float period, 53 | wippersnapper_pin_v1_ConfigurePinRequest_Pull pullMode, 54 | wippersnapper_pin_v1_ConfigurePinRequest_AnalogReadMode analogReadMode); 55 | void 56 | deinitAnalogPin(wippersnapper_pin_v1_ConfigurePinRequest_Direction direction, 57 | int pin); 58 | void disableAnalogInPin(int pin); 59 | 60 | uint16_t getPinValue(int pin); 61 | float getPinValueVolts(int pin); 62 | 63 | void setADCResolution(int resolution); 64 | int getADCresolution(); 65 | int getNativeResolution(); 66 | bool timerExpired(long currentTime, analogInputPin pin, 67 | long periodOffset = 0); 68 | 69 | void update(); 70 | bool encodePinEvent( 71 | uint8_t pinName, 72 | wippersnapper_pin_v1_ConfigurePinRequest_AnalogReadMode readMode, 73 | uint16_t pinValRaw = 0, float pinValVolts = 0.0); 74 | 75 | private: 76 | float _aRef; /*!< Hardware's reported voltage reference */ 77 | int _adcResolution; /*!< Resolution returned by the analogRead() funcn. */ 78 | int _nativeResolution; /*!< Hardware's native ADC resolution. */ 79 | bool scaleAnalogRead = false; /*!< True if we need to manually scale the value 80 | returned by analogRead(). */ 81 | int32_t _totalAnalogInputPins; /*!< Total number of analog input pins */ 82 | analogInputPin *_analog_input_pins; /*!< Array of analog pin objects */ 83 | }; 84 | extern Wippersnapper WS; /*!< Wippersnapper variable. */ 85 | 86 | #endif // WIPPERSNAPPER_DIGITALGPIO_H -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_QMC5883P.cpp 3 | * 4 | * Implementation for the Adafruit QMC5883P magnetometer wrapper. 5 | */ 6 | 7 | #include "WipperSnapper_I2C_Driver_QMC5883P.h" 8 | 9 | #include 10 | 11 | /*! 12 | * @brief Constructor for a QMC5883P sensor. 13 | * @param i2c 14 | * The I2C interface. 15 | * @param sensorAddress 16 | * The 7-bit I2C address of the sensor. 17 | */ 18 | WipperSnapper_I2C_Driver_QMC5883P::WipperSnapper_I2C_Driver_QMC5883P( 19 | TwoWire *i2c, uint16_t sensorAddress) 20 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) {} 21 | 22 | /*! 23 | * @brief Destructor for a QMC5883P sensor. 24 | */ 25 | WipperSnapper_I2C_Driver_QMC5883P::~WipperSnapper_I2C_Driver_QMC5883P() { 26 | if (_qmc) { 27 | delete _qmc; 28 | } 29 | } 30 | 31 | /*! 32 | * @brief Initializes the QMC5883P sensor and begins I2C. 33 | * @return True if initialized successfully, False otherwise. 34 | */ 35 | bool WipperSnapper_I2C_Driver_QMC5883P::begin() { 36 | _qmc = new Adafruit_QMC5883P(); 37 | if (!_qmc->begin(_sensorAddress, _i2c)) { 38 | return false; 39 | } 40 | 41 | // Set to continuous mode 42 | _qmc->setMode(QMC5883P_MODE_CONTINUOUS); 43 | // Set ODR (Output Data Rate) to 50Hz 44 | _qmc->setODR(QMC5883P_ODR_50HZ); 45 | // Set OSR (Over Sample Ratio) to 4 46 | _qmc->setOSR(QMC5883P_OSR_4); 47 | // Set DSR (Downsample Ratio) to 2 48 | _qmc->setDSR(QMC5883P_DSR_2); 49 | // Set Range to 30G 50 | _qmc->setRange(QMC5883P_RANGE_30G); 51 | // Set SetReset mode to On 52 | _qmc->setSetResetMode(QMC5883P_SETRESET_ON); 53 | 54 | return true; 55 | } 56 | 57 | /*! 58 | * @brief Get the magnetometer's sensor event. 59 | * @param magEvent 60 | * Pointer to the magnetometer sensor event. 61 | * @return True if the event was obtained successfully, False otherwise. 62 | */ 63 | bool WipperSnapper_I2C_Driver_QMC5883P::getEventRaw(sensors_event_t *magEvent) { 64 | if (!_qmc->isDataReady()) { 65 | return false; 66 | } 67 | 68 | int16_t x, y, z; 69 | float gx, gy, gz; 70 | 71 | // Get raw magnetic data 72 | if (!_qmc->getRawMagnetic(&x, &y, &z)) { 73 | WS_DEBUG_PRINTLN("Failed to read raw magnetic data"); 74 | return false; 75 | } 76 | 77 | // Get Gauss field data 78 | if (!_qmc->getGaussField(&gx, &gy, &gz)) { 79 | WS_DEBUG_PRINTLN("Failed to read Gauss field data"); 80 | WS_DEBUG_PRINT("Raw X: "); 81 | WS_DEBUG_PRINTLN(x); 82 | WS_DEBUG_PRINT("Raw Y: "); 83 | WS_DEBUG_PRINTLN(y); 84 | WS_DEBUG_PRINT("Raw Z: "); 85 | WS_DEBUG_PRINTLN(z); 86 | return false; 87 | } else { 88 | WS_DEBUG_PRINT("Gauss X: "); 89 | WS_DEBUG_PRINTLN(gx); 90 | WS_DEBUG_PRINT("Gauss Y: "); 91 | WS_DEBUG_PRINTLN(gy); 92 | WS_DEBUG_PRINT("Gauss Z: "); 93 | WS_DEBUG_PRINTLN(gz); 94 | } 95 | 96 | // Check for overflow 97 | if (_qmc->isOverflow()) { 98 | WS_DEBUG_PRINTLN("QMC5883P data overflow - skipping reading"); 99 | return false; 100 | } 101 | 102 | // Calculate magnitude in Gauss 103 | float magnitude_G = sqrtf(gx * gx + gy * gy + gz * gz); 104 | magEvent->data[0] = magnitude_G; 105 | return true; 106 | } 107 | -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_VEML7700.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_VEML7700.h 3 | * 4 | * Device driver for the VEML7700 digital luminosity (light) sensor. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Tyeth Gundry 2022 for Adafruit Industries. 11 | * 12 | * MIT license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef WipperSnapper_I2C_Driver_VEML7700_H 16 | #define WipperSnapper_I2C_Driver_VEML7700_H 17 | 18 | #include "WipperSnapper_I2C_Driver.h" 19 | #include 20 | 21 | /**************************************************************************/ 22 | /*! 23 | @brief Class that provides a driver interface for a VEML7700 sensor. 24 | */ 25 | /**************************************************************************/ 26 | class WipperSnapper_I2C_Driver_VEML7700 : public WipperSnapper_I2C_Driver { 27 | public: 28 | /*******************************************************************************/ 29 | /*! 30 | @brief Constructor for a VEML7700 sensor. 31 | @param i2c 32 | The I2C interface. 33 | @param sensorAddress 34 | The 7-bit I2C address of the sensor. 35 | */ 36 | /*******************************************************************************/ 37 | WipperSnapper_I2C_Driver_VEML7700(TwoWire *i2c, uint16_t sensorAddress) 38 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 39 | _i2c = i2c; 40 | _sensorAddress = sensorAddress; 41 | } 42 | 43 | /*******************************************************************************/ 44 | /*! 45 | @brief Destructor for an VEML7700 sensor. 46 | */ 47 | /*******************************************************************************/ 48 | ~WipperSnapper_I2C_Driver_VEML7700() { delete _veml; } 49 | 50 | /*******************************************************************************/ 51 | /*! 52 | @brief Initializes the VEML7700 sensor and begins I2C. 53 | @returns True if initialized successfully, False otherwise. 54 | */ 55 | /*******************************************************************************/ 56 | bool begin() { 57 | _veml = new Adafruit_VEML7700(); 58 | // Attempt to initialize and configure VEML7700 59 | return _veml->begin(_i2c); 60 | } 61 | 62 | /*******************************************************************************/ 63 | /*! 64 | @brief Performs a light sensor read using the Adafruit 65 | Unified Sensor API. Always uses VEML_LUX_AUTO, 66 | controlling sensor integration time and gain. 67 | @param lightEvent 68 | Light sensor reading, in lux. 69 | @returns True if the sensor event was obtained successfully, False 70 | otherwise. 71 | */ 72 | /*******************************************************************************/ 73 | bool getEventLight(sensors_event_t *lightEvent) { 74 | // Get sensor event populated in lux via AUTO integration and gain 75 | lightEvent->light = _veml->readLux(VEML_LUX_AUTO); 76 | 77 | return true; 78 | } 79 | 80 | protected: 81 | Adafruit_VEML7700 *_veml; ///< Pointer to VEML7700 light sensor object 82 | }; 83 | 84 | #endif // WipperSnapper_I2C_Driver_VEML7700 -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_HTU31D.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_HTU31D.h 3 | * 4 | * Device driver for an HTU31D Humidity and Temperature sensor. 5 | */ 6 | 7 | #ifndef WipperSnapper_I2C_Driver_HTU31D_H 8 | #define WipperSnapper_I2C_Driver_HTU31D_H 9 | 10 | #include "WipperSnapper_I2C_Driver.h" 11 | #include 12 | 13 | /**************************************************************************/ 14 | /*! 15 | @brief Class that provides a sensor driver for the HTU31D humidity and 16 | temperature sensor. 17 | */ 18 | /**************************************************************************/ 19 | class WipperSnapper_I2C_Driver_HTU31D : public WipperSnapper_I2C_Driver { 20 | 21 | public: 22 | /*******************************************************************************/ 23 | /*! 24 | @brief Constructor for an HTU31D sensor. 25 | @param i2c 26 | The I2C interface. 27 | @param sensorAddress 28 | 7-bit device address. 29 | */ 30 | /*******************************************************************************/ 31 | WipperSnapper_I2C_Driver_HTU31D(TwoWire *i2c, uint16_t sensorAddress) 32 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 33 | _i2c = i2c; 34 | _sensorAddress = sensorAddress; 35 | } 36 | 37 | /*******************************************************************************/ 38 | /*! 39 | @brief Destructor for an HTU31D sensor. 40 | */ 41 | /*******************************************************************************/ 42 | ~WipperSnapper_I2C_Driver_HTU31D() { delete _htu31d; } 43 | 44 | /*******************************************************************************/ 45 | /*! 46 | @brief Initializes the HTU31D sensor and begins I2C. 47 | @returns True if initialized successfully, False otherwise. 48 | 49 | */ 50 | /*******************************************************************************/ 51 | bool begin() { 52 | // attempt to initialize the HTU31D using the I2C interface 53 | _htu31d = new Adafruit_HTU31D(); 54 | return _htu31d->begin(_sensorAddress, _i2c); 55 | } 56 | 57 | /*******************************************************************************/ 58 | /*! 59 | @brief Gets the HTU31D's current temperature. 60 | @param tempEvent 61 | Pointer to an Adafruit_Sensor event. 62 | @returns True if the temperature was obtained successfully, False 63 | otherwise. 64 | */ 65 | /*******************************************************************************/ 66 | bool getEventAmbientTemp(sensors_event_t *tempEvent) { 67 | return _htu31d->getEvent(nullptr, tempEvent); 68 | } 69 | 70 | /*******************************************************************************/ 71 | /*! 72 | @brief Gets the HTU31D's current humidity. 73 | @param humidEvent 74 | Pointer to an Adafruit_Sensor event. 75 | @returns True if the humidity was obtained successfully, False 76 | otherwise. 77 | */ 78 | /*******************************************************************************/ 79 | bool getEventRelativeHumidity(sensors_event_t *humidEvent) { 80 | return _htu31d->getEvent(humidEvent, nullptr); 81 | } 82 | 83 | protected: 84 | Adafruit_HTU31D *_htu31d; ///< Pointer to an HTU31D object 85 | }; 86 | 87 | #endif // WipperSnapper_I2C_Driver_HTU31D -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_HTU21D.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_HTU21D.h 3 | * 4 | * Device driver for an HTU21D Humidity and Temperature sensor. 5 | */ 6 | 7 | #ifndef WipperSnapper_I2C_Driver_HTU21D_H 8 | #define WipperSnapper_I2C_Driver_HTU21D_H 9 | 10 | #include "WipperSnapper_I2C_Driver.h" 11 | #include 12 | 13 | /**************************************************************************/ 14 | /*! 15 | @brief Class that provides a sensor driver for the HTU21D humidity and 16 | temperature sensor. 17 | */ 18 | /**************************************************************************/ 19 | class WipperSnapper_I2C_Driver_HTU21D : public WipperSnapper_I2C_Driver { 20 | 21 | public: 22 | /*******************************************************************************/ 23 | /*! 24 | @brief Constructor for an HTU21D sensor. 25 | @param i2c 26 | The I2C interface. 27 | @param sensorAddress 28 | 7-bit device address. 29 | */ 30 | /*******************************************************************************/ 31 | WipperSnapper_I2C_Driver_HTU21D(TwoWire *i2c, uint16_t sensorAddress) 32 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 33 | _i2c = i2c; 34 | _sensorAddress = sensorAddress; 35 | } 36 | 37 | /*******************************************************************************/ 38 | /*! 39 | @brief Destructor for an HTU21D sensor. 40 | */ 41 | /*******************************************************************************/ 42 | ~WipperSnapper_I2C_Driver_HTU21D() { delete _htu21d; } 43 | 44 | /*******************************************************************************/ 45 | /*! 46 | @brief Initializes the HTU21D sensor and begins I2C. 47 | @returns True if initialized successfully, False otherwise. 48 | 49 | */ 50 | /*******************************************************************************/ 51 | bool begin() { 52 | // attempt to initialize the HTU21D using the I2C interface 53 | _htu21d = new Adafruit_HTU21DF(); 54 | return _htu21d->begin(_i2c); 55 | } 56 | 57 | /*******************************************************************************/ 58 | /*! 59 | @brief Gets the HTU21D's current temperature. 60 | @param tempEvent 61 | Pointer to an Adafruit_Sensor event. 62 | @returns True if the temperature was obtained successfully, False 63 | otherwise. 64 | */ 65 | /*******************************************************************************/ 66 | bool getEventAmbientTemp(sensors_event_t *tempEvent) { 67 | tempEvent->temperature = _htu21d->readTemperature(); 68 | return true; 69 | } 70 | 71 | /*******************************************************************************/ 72 | /*! 73 | @brief Gets the HTU21D's current humidity. 74 | @param humidEvent 75 | Pointer to an Adafruit_Sensor event. 76 | @returns True if the humidity was obtained successfully, False 77 | otherwise. 78 | */ 79 | /*******************************************************************************/ 80 | bool getEventRelativeHumidity(sensors_event_t *humidEvent) { 81 | humidEvent->relative_humidity = _htu21d->readHumidity(); 82 | return true; 83 | } 84 | 85 | protected: 86 | Adafruit_HTU21DF *_htu21d; ///< Pointer to an HTU21D object 87 | }; 88 | 89 | #endif // WipperSnapper_I2C_Driver_HTU21D -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_VL53L0X.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_VL53L0X.h 3 | * 4 | * Device driver for the VL53L0X ToF sensor. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) 2022 afp316 https://github.com/afp316 11 | * Modified (c) by Tyeth Gundry https://github.com/tyeth 12 | * 13 | * MIT license, all text here must be included in any redistribution. 14 | * 15 | */ 16 | #ifndef WipperSnapper_I2C_Driver_VL53L0X_H 17 | #define WipperSnapper_I2C_Driver_VL53L0X_H 18 | 19 | #include "WipperSnapper_I2C_Driver.h" 20 | #include 21 | 22 | /**************************************************************************/ 23 | /*! 24 | @brief Class that provides a driver interface for a VL53L0X sensor. 25 | */ 26 | /**************************************************************************/ 27 | class WipperSnapper_I2C_Driver_VL53L0X : public WipperSnapper_I2C_Driver { 28 | public: 29 | /*******************************************************************************/ 30 | /*! 31 | @brief Constructor for a VL53L0X sensor. 32 | @param i2c 33 | The I2C interface. 34 | @param sensorAddress 35 | 7-bit device address. 36 | */ 37 | /*******************************************************************************/ 38 | WipperSnapper_I2C_Driver_VL53L0X(TwoWire *i2c, uint16_t sensorAddress) 39 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 40 | _i2c = i2c; 41 | _sensorAddress = sensorAddress; 42 | } 43 | 44 | /*******************************************************************************/ 45 | /*! 46 | @brief Destructor for an VL53L0X sensor. 47 | */ 48 | /*******************************************************************************/ 49 | ~WipperSnapper_I2C_Driver_VL53L0X() { 50 | // Called when a VL53L0X component is deleted. 51 | delete _vl53l0x; 52 | } 53 | 54 | /*******************************************************************************/ 55 | /*! 56 | @brief Initializes the VL53L0X sensor and begins I2C. 57 | @returns True if initialized successfully, False otherwise. 58 | */ 59 | /*******************************************************************************/ 60 | bool begin() { 61 | _vl53l0x = new Adafruit_VL53L0X(); 62 | bool isInit = 63 | _vl53l0x->begin((uint8_t)_sensorAddress, false, _i2c, 64 | Adafruit_VL53L0X::VL53L0X_SENSE_HIGH_ACCURACY); 65 | return isInit; 66 | } 67 | 68 | /*******************************************************************************/ 69 | /*! 70 | @brief Gets the VL53L0X's current proximity. 71 | @param proximityEvent 72 | Pointer to an Adafruit_Sensor event. 73 | @returns True if the proximity was obtained successfully, False 74 | otherwise. 75 | */ 76 | /*******************************************************************************/ 77 | bool getEventProximity(sensors_event_t *proximityEvent) { 78 | u_int16_t proximityMM = _vl53l0x->readRange(); 79 | if (proximityMM == 0xffff) { 80 | proximityEvent->data[0] = NAN; 81 | } else { 82 | proximityEvent->data[0] = proximityMM; 83 | } 84 | return true; 85 | } 86 | 87 | protected: 88 | Adafruit_VL53L0X *_vl53l0x; ///< Pointer to VL53L0X temperature sensor object 89 | }; 90 | 91 | #endif // WipperSnapper_I2C_Driver_VL53L0X -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_BH1750.h: -------------------------------------------------------------------------------- 1 | #ifndef WipperSnapper_I2C_Driver_BH1750_H 2 | #define WipperSnapper_I2C_Driver_BH1750_H 3 | 4 | #include "WipperSnapper_I2C_Driver.h" 5 | #include //include the library for the BH1750 sensor 6 | 7 | /**************************************************************************/ 8 | /*! 9 | @brief Class that provides a driver interface for a BH1750 Light sensor. 10 | 11 | This driver uses the H-Resolution Mode and the default measurement 12 | time register (MTreg) of 69. According to the datasheet this is 13 | the recommended mode for most applications. Typical measurement 14 | time in this mode is 120ms 15 | 16 | This driver uses the One Time Measurement feature of the BH1750. The 17 | sensor returns to Power Down mode after each reading. 18 | */ 19 | /**************************************************************************/ 20 | class WipperSnapper_I2C_Driver_BH1750 : public WipperSnapper_I2C_Driver { 21 | public: 22 | /*******************************************************************************/ 23 | /*! 24 | @brief Constructor for a BH1750 sensor. 25 | @param i2c 26 | The I2C interface. 27 | @param sensorAddress 28 | 7-bit device address. 29 | */ 30 | /*******************************************************************************/ 31 | WipperSnapper_I2C_Driver_BH1750(TwoWire *i2c, uint16_t sensorAddress) 32 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 33 | _i2c = i2c; 34 | _sensorAddress = sensorAddress; 35 | } 36 | 37 | /*******************************************************************************/ 38 | /*! 39 | @brief Destructor for a BH1750 sensor. 40 | */ 41 | /*******************************************************************************/ 42 | ~WipperSnapper_I2C_Driver_BH1750() { 43 | // Called when a BH1750 component is deleted. 44 | delete _bh1750; 45 | } 46 | 47 | /*******************************************************************************/ 48 | /*! 49 | @brief Initializes the BH1750 sensor and begins I2C. 50 | The set the quality to the H-Resolution Mode. 51 | @returns True if initialized successfully, False otherwise. 52 | */ 53 | /*******************************************************************************/ 54 | bool begin() { 55 | _bh1750 = new hp_BH1750(); 56 | // attempt to initialize BH1750 57 | if (!_bh1750->begin(_sensorAddress, _i2c)) 58 | return false; 59 | // Set to the recommended quality setting 60 | _bh1750->setQuality(BH1750_QUALITY_HIGH); 61 | return true; 62 | } 63 | 64 | /*******************************************************************************/ 65 | /*! 66 | @brief Performs a light sensor read using the One Time Measurement 67 | feature of the BH1750. The sensor goes to Power Down mode after 68 | each reading. 69 | @param lightEvent 70 | Light sensor reading, in lux. 71 | @returns True if the sensor event was obtained successfully, False 72 | otherwise. 73 | */ 74 | /*******************************************************************************/ 75 | bool getEventLight(sensors_event_t *lightEvent) { 76 | _bh1750->start(); 77 | lightEvent->light = _bh1750->getLux(); 78 | return true; 79 | } 80 | 81 | protected: 82 | hp_BH1750 *_bh1750; ///< Pointer to BH1750 light sensor object 83 | }; 84 | 85 | #endif // WipperSnapper_I2C_Driver_BH1750 -------------------------------------------------------------------------------- /src/components/ledc/ws_ledc.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file ws_ledc.cpp 3 | * 4 | * This is the documentation for WipperSnapper's LEDC peripheral 5 | * management API. It is used by drivers like ledc_servo. 6 | * 7 | * Adafruit invests time and resources providing this open source code, 8 | * please support Adafruit and open-source hardware by purchasing 9 | * products from Adafruit! 10 | * 11 | * Written by Brent Rubell for Adafruit Industries, 2022-2023 12 | * 13 | * MIT license, all text here must be included in any redistribution. 14 | * 15 | */ 16 | #if defined(ARDUINO_ARCH_ESP32) 17 | 18 | #include "ws_ledc.h" 19 | 20 | /**************************************************************************/ 21 | /*! 22 | @brief Sets up a LEDC pin with given frequency and resolution. 23 | @param pin Desired GPIO pin number. 24 | @param freq Desired timer frequency, in Hz. 25 | @param resolution Desired timer resolution, in bits. 26 | @return True if configuration is successful. False is returned if error 27 | occurs and LEDC channel was not configured. 28 | */ 29 | /**************************************************************************/ 30 | bool ws_ledc::attachPin(uint8_t pin, uint32_t freq, uint8_t resolution) { 31 | return ledcAttach(pin, freq, resolution); 32 | } 33 | 34 | /**************************************************************************/ 35 | /*! 36 | @brief Detaches a pin from LEDC. 37 | @param pin Desired GPIO pin number. 38 | @return True if successfully detached, False otherwise. 39 | */ 40 | /**************************************************************************/ 41 | bool ws_ledc::detachPin(uint8_t pin) { return ledcDetach(pin); } 42 | 43 | /**************************************************************************/ 44 | /*! 45 | @brief Arduino AnalogWrite function, but for ESP32's LEDC. 46 | @param pin The desired pin to write to. 47 | @param value The duty cycle. 48 | @return True if PWM value written to LEDC pin, False otherwise. 49 | */ 50 | /**************************************************************************/ 51 | bool ws_ledc::analogWrite(uint8_t pin, int value) { 52 | if (value > 255 || value < 0) 53 | return false; 54 | 55 | // Calculate duty cycle for the `value` passed in 56 | // (assumes 12-bit resolution, 2^12) 57 | uint32_t dutyCycle = 58 | (uint32_t)(((double)4095 / 255.0) * min((uint32_t)value, (uint32_t)255)); 59 | 60 | // Call duty cycle write 61 | return setDuty(pin, dutyCycle); 62 | } 63 | 64 | /**************************************************************************/ 65 | /*! 66 | @brief Sets the duty cycle of a LEDC pin. 67 | @param pin Desired GPIO pin to write to. 68 | @param duty Desired duty cycle. 69 | @return True if duty cycle was set, False otherwise. 70 | */ 71 | /**************************************************************************/ 72 | bool ws_ledc::setDuty(uint8_t pin, uint32_t duty) { 73 | return ledcWrite(pin, duty); 74 | } 75 | 76 | /**************************************************************************/ 77 | /*! 78 | @brief Writes a square wave with a fixed duty cycle and variable 79 | frequency to a pin. Used by piezo buzzers and speakers. 80 | @param pin The desired pin to write to. 81 | @param freq The frequency of the tone, in Hz. 82 | @return The frequency of the LEDC pin. 0 if error occurs and LEDC pin was 83 | not configured. 84 | */ 85 | /**************************************************************************/ 86 | uint32_t ws_ledc::tone(uint8_t pin, uint32_t freq) { 87 | return ledcWriteTone(pin, freq); 88 | } 89 | 90 | #endif // ARDUINO_ARCH_ESP32 -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_SHTC3.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_SHTC3.h 3 | * 4 | * Device driver for the SHTC3 Temperature and Humidity Sensor 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Marni Brewster 2022 for Adafruit Industries. 11 | * Copyright (c) Tyeth Gundry 2022. Original code by Marni, 12 | * rewritten to use driver by Sensirion, help from Brent Rubell. 13 | * 14 | * MIT license, all text here must be included in any redistribution. 15 | * 16 | */ 17 | 18 | #ifndef WipperSnapper_I2C_Driver_SHTC3_H 19 | #define WipperSnapper_I2C_Driver_SHTC3_H 20 | 21 | #include "WipperSnapper_I2C_Driver.h" 22 | #include 23 | #include 24 | 25 | /**************************************************************************/ 26 | /*! 27 | @brief Class that provides a driver interface for the SHTC3 sensor. 28 | */ 29 | /**************************************************************************/ 30 | class WipperSnapper_I2C_Driver_SHTC3 : public WipperSnapper_I2C_Driver { 31 | 32 | public: 33 | /*******************************************************************************/ 34 | /*! 35 | @brief Constructor for a SHTC3 sensor. 36 | @param i2c 37 | The I2C interface. 38 | @param sensorAddress 39 | 7-bit device address. 40 | */ 41 | /*******************************************************************************/ 42 | WipperSnapper_I2C_Driver_SHTC3(TwoWire *i2c, uint16_t sensorAddress) 43 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 44 | _i2c = i2c; 45 | _sensorAddress = sensorAddress; 46 | } 47 | 48 | /*******************************************************************************/ 49 | /*! 50 | @brief Initializes the SHTC3 sensor and begins I2C. 51 | @returns True if initialized successfully, False otherwise. 52 | */ 53 | /*******************************************************************************/ 54 | bool begin() { 55 | _shtc3 = new SHTSensor(SHTSensor::SHTC3); 56 | return _shtc3->init(*_i2c); 57 | } 58 | 59 | /*******************************************************************************/ 60 | /*! 61 | @brief Gets the SHTC3's current temperature. 62 | @param tempEvent 63 | Pointer to an Adafruit_Sensor event. 64 | @returns True if the temperature was obtained successfully, False 65 | otherwise. 66 | */ 67 | /*******************************************************************************/ 68 | bool getEventAmbientTemp(sensors_event_t *tempEvent) { 69 | // populate temp and humidity objects with fresh data 70 | if (!_shtc3->readSample()) 71 | return false; 72 | tempEvent->temperature = _shtc3->getTemperature(); 73 | return true; 74 | } 75 | 76 | /*******************************************************************************/ 77 | /*! 78 | @brief Gets the SHTC3's current relative humidity reading. 79 | @param humidEvent 80 | Pointer to an Adafruit_Sensor event. 81 | @returns True if the humidity was obtained successfully, False 82 | otherwise. 83 | */ 84 | /*******************************************************************************/ 85 | bool getEventRelativeHumidity(sensors_event_t *humidEvent) { 86 | // populate temp and humidity objects with fresh data 87 | if (!_shtc3->readSample()) 88 | return false; 89 | humidEvent->relative_humidity = _shtc3->getHumidity(); 90 | return true; 91 | } 92 | 93 | protected: 94 | SHTSensor *_shtc3; ///< SHTC3 object 95 | }; 96 | 97 | #endif // WipperSnapper_I2C_Driver_SHTC3 -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_VCNL4020.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_VCNL4020.h 3 | * 4 | * Device driver for the VCNL4020 light + proximity sensor. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Tyeth Gundry 2023 for Adafruit Industries. 11 | * 12 | * MIT license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef WipperSnapper_I2C_Driver_VCNL4020_H 16 | #define WipperSnapper_I2C_Driver_VCNL4020_H 17 | 18 | #include "WipperSnapper_I2C_Driver.h" 19 | #include 20 | 21 | /**************************************************************************/ 22 | /*! 23 | @brief Class that provides a driver interface for a VCNL4020 sensor. 24 | */ 25 | /**************************************************************************/ 26 | class WipperSnapper_I2C_Driver_VCNL4020 : public WipperSnapper_I2C_Driver { 27 | public: 28 | /*******************************************************************************/ 29 | /*! 30 | @brief Constructor for a VCNL4020 sensor. 31 | @param i2c 32 | The I2C interface. 33 | @param sensorAddress 34 | The 7-bit I2C address of the sensor. 35 | */ 36 | /*******************************************************************************/ 37 | WipperSnapper_I2C_Driver_VCNL4020(TwoWire *i2c, uint16_t sensorAddress) 38 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 39 | _i2c = i2c; 40 | _sensorAddress = sensorAddress; 41 | } 42 | 43 | /*******************************************************************************/ 44 | /*! 45 | @brief Destructor for an VCNL4020 sensor. 46 | */ 47 | /*******************************************************************************/ 48 | ~WipperSnapper_I2C_Driver_VCNL4020() { delete _vcnl4020; } 49 | 50 | /*******************************************************************************/ 51 | /*! 52 | @brief Initializes the VCNL4020 sensor and begins I2C. 53 | @returns True if initialized successfully, False otherwise. 54 | */ 55 | /*******************************************************************************/ 56 | bool begin() { 57 | _vcnl4020 = new Adafruit_VCNL4020(); 58 | // Attempt to initialize and configure VCNL4020 59 | return _vcnl4020->begin(_i2c, _sensorAddress); 60 | } 61 | 62 | /*******************************************************************************/ 63 | /*! 64 | @brief Performs a light sensor read using the Adafruit 65 | Unified Sensor API. 66 | @param lightEvent 67 | Light sensor reading, in lux. 68 | @returns True if the sensor event was obtained successfully, False 69 | otherwise. 70 | */ 71 | /*******************************************************************************/ 72 | bool getEventLight(sensors_event_t *lightEvent) { 73 | // Get sensor event populated in lux via AUTO integration and gain 74 | lightEvent->light = _vcnl4020->readAmbient(); 75 | return true; 76 | } 77 | 78 | /*******************************************************************************/ 79 | /*! 80 | @brief Reads the VCNL4020's proximity value into an event (no unit). 81 | @param proximityEvent 82 | Pointer to an Adafruit_Sensor event. 83 | @returns True if the proximity was obtained successfully, False 84 | otherwise. 85 | */ 86 | /*******************************************************************************/ 87 | bool getEventProximity(sensors_event_t *proximityEvent) { 88 | proximityEvent->data[0] = (float)_vcnl4020->readProximity(); 89 | return true; 90 | } 91 | 92 | protected: 93 | Adafruit_VCNL4020 *_vcnl4020; ///< Pointer to VCNL4020 light sensor object 94 | }; 95 | 96 | #endif // WipperSnapper_I2C_Driver_VCNL4020 -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_MAX17048.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_MAX17048.h 3 | * 4 | * Device driver for the MAX17048/MAX17049 LiPoly / LiIon Fuel Gauge and Battery 5 | * Monitor 6 | * 7 | * Adafruit invests time and resources providing this open source code, 8 | * please support Adafruit and open-source hardware by purchasing 9 | * products from Adafruit! 10 | * 11 | * Copyright (c) Brent Rubell 2023 for Adafruit Industries. 12 | * 13 | * MIT license, all text here must be included in any redistribution. 14 | * 15 | */ 16 | #ifndef WipperSnapper_I2C_Driver_MAX17048_H 17 | #define WipperSnapper_I2C_Driver_MAX17048_H 18 | 19 | #include "WipperSnapper_I2C_Driver.h" 20 | #include 21 | 22 | /**************************************************************************/ 23 | /*! 24 | @brief Class that provides a driver interface for a MAX17048 sensor. 25 | */ 26 | /**************************************************************************/ 27 | class WipperSnapper_I2C_Driver_MAX17048 : public WipperSnapper_I2C_Driver { 28 | public: 29 | /*******************************************************************************/ 30 | /*! 31 | @brief Constructor for a MAX17048 sensor. 32 | @param i2c 33 | The I2C interface. 34 | @param sensorAddress 35 | The 7-bit I2C address of the sensor. 36 | */ 37 | /*******************************************************************************/ 38 | WipperSnapper_I2C_Driver_MAX17048(TwoWire *i2c, uint16_t sensorAddress) 39 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 40 | _i2c = i2c; 41 | _sensorAddress = sensorAddress; 42 | } 43 | 44 | /*******************************************************************************/ 45 | /*! 46 | @brief Destructor for an MAX17048 sensor. 47 | */ 48 | /*******************************************************************************/ 49 | ~WipperSnapper_I2C_Driver_MAX17048() { delete _maxlipo; } 50 | 51 | /*******************************************************************************/ 52 | /*! 53 | @brief Initializes the MAX17048 sensor and begins I2C. 54 | @returns True if initialized successfully, False otherwise. 55 | */ 56 | /*******************************************************************************/ 57 | bool begin() { 58 | _maxlipo = new Adafruit_MAX17048(); 59 | if (!_maxlipo->begin(_i2c)) 60 | return false; 61 | return true; 62 | } 63 | 64 | /*******************************************************************************/ 65 | /*! 66 | @brief Reads a voltage sensor and converts the 67 | reading into the expected SI unit. 68 | @param voltageEvent 69 | voltage sensor reading, in volts. 70 | @returns True if the sensor event was obtained successfully, False 71 | otherwise. 72 | */ 73 | /*******************************************************************************/ 74 | bool getEventVoltage(sensors_event_t *voltageEvent) { 75 | voltageEvent->voltage = _maxlipo->cellVoltage(); 76 | return true; 77 | } 78 | 79 | /*******************************************************************************/ 80 | /*! 81 | @brief Reads a sensor's unitless % reading and 82 | converts the reading into the expected SI unit. 83 | @param unitlessPercentEvent 84 | unitless % sensor reading. 85 | @returns True if the sensor event was obtained successfully, False 86 | otherwise. 87 | */ 88 | /*******************************************************************************/ 89 | bool getEventUnitlessPercent(sensors_event_t *unitlessPercentEvent) { 90 | unitlessPercentEvent->unitless_percent = _maxlipo->cellPercent(); 91 | return true; 92 | } 93 | 94 | protected: 95 | Adafruit_MAX17048 *_maxlipo; ///< Pointer to MAX17048 sensor object 96 | }; 97 | 98 | #endif // WipperSnapper_I2C_Driver_MAX17048 -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_VL53L1X.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_VL53L1X.h 3 | * 4 | * Device driver for the VL53L1X ToF sensor. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) 2022 afp316 https://github.com/afp316 11 | * Modified Tyeth Gundry 2023 for Adafruit Industries. 12 | * 13 | * MIT license, all text here must be included in any redistribution. 14 | * 15 | */ 16 | #ifndef WipperSnapper_I2C_Driver_VL53L1X_H 17 | #define WipperSnapper_I2C_Driver_VL53L1X_H 18 | 19 | #include "WipperSnapper_I2C_Driver.h" 20 | #include 21 | 22 | /**************************************************************************/ 23 | /*! 24 | @brief Class that provides a driver interface for a VL53L1X sensor. 25 | */ 26 | /**************************************************************************/ 27 | class WipperSnapper_I2C_Driver_VL53L1X : public WipperSnapper_I2C_Driver { 28 | public: 29 | /*******************************************************************************/ 30 | /*! 31 | @brief Constructor for a VL53L1X sensor. 32 | @param i2c 33 | The I2C interface. 34 | @param sensorAddress 35 | 7-bit device address. 36 | */ 37 | /*******************************************************************************/ 38 | WipperSnapper_I2C_Driver_VL53L1X(TwoWire *i2c, uint16_t sensorAddress) 39 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 40 | _i2c = i2c; 41 | _sensorAddress = sensorAddress; 42 | } 43 | 44 | /*******************************************************************************/ 45 | /*! 46 | @brief Destructor for an VL53L1X sensor. 47 | */ 48 | /*******************************************************************************/ 49 | ~WipperSnapper_I2C_Driver_VL53L1X() { 50 | // Called when a VL53L1X component is deleted. 51 | delete _VL53L1X; 52 | } 53 | 54 | /*******************************************************************************/ 55 | /*! 56 | @brief Initializes the VL53L1X sensor and begins I2C. 57 | @returns True if initialized successfully, False otherwise. 58 | */ 59 | /*******************************************************************************/ 60 | bool begin() { 61 | _VL53L1X = new Adafruit_VL53L1X(); 62 | if (_VL53L1X->begin((uint8_t)_sensorAddress, _i2c, false)) { 63 | _VL53L1X->startRanging(); 64 | _VL53L1X->setTimingBudget(500); // distance mode is long(2) by default 65 | return true; 66 | } 67 | return false; 68 | } 69 | 70 | /*******************************************************************************/ 71 | /*! 72 | @brief Gets the VL53L1X's current proximity. 73 | @param proximityEvent 74 | Pointer to an Adafruit_Sensor event. 75 | @returns True if the proximity was obtained successfully, False 76 | otherwise. 77 | */ 78 | /*******************************************************************************/ 79 | bool getEventProximity(sensors_event_t *proximityEvent) { 80 | if (!_VL53L1X->dataReady()) { 81 | return false; 82 | } 83 | int16_t proximityMM = _VL53L1X->distance(); 84 | if (proximityMM == -1) { 85 | WS_DEBUG_PRINT("VL53L1X: Invalid proximity value:"); 86 | WS_DEBUG_PRINTLN(proximityMM); 87 | WS_DEBUG_PRINT("VL53L1X status: "); 88 | WS_DEBUG_PRINTLN(_VL53L1X->vl_status); 89 | proximityEvent->data[0] = NAN; 90 | } else { 91 | proximityEvent->data[0] = proximityMM; 92 | _VL53L1X->clearInterrupt(); 93 | } 94 | return true; 95 | } 96 | 97 | protected: 98 | Adafruit_VL53L1X *_VL53L1X; ///< Pointer to VL53L1X temperature sensor object 99 | }; 100 | 101 | #endif // WipperSnapper_I2C_Driver_VL53L1X -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_TSL2591.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_TSL2591.h 3 | * 4 | * Device driver for the TSL2591 digital luminosity (light) sensor. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Brent Rubell 2022 for Adafruit Industries. 11 | * 12 | * MIT license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef WipperSnapper_I2C_Driver_TSL2591_H 16 | #define WipperSnapper_I2C_Driver_TSL2591_H 17 | 18 | #include "WipperSnapper_I2C_Driver.h" 19 | #include 20 | 21 | /**************************************************************************/ 22 | /*! 23 | @brief Class that provides a driver interface for a TSL2591 sensor. 24 | */ 25 | /**************************************************************************/ 26 | class WipperSnapper_I2C_Driver_TSL2591 : public WipperSnapper_I2C_Driver { 27 | public: 28 | /*******************************************************************************/ 29 | /*! 30 | @brief Constructor for a TSL2591 sensor. 31 | @param i2c 32 | The I2C interface. 33 | @param sensorAddress 34 | The 7-bit I2C address of the sensor. 35 | */ 36 | /*******************************************************************************/ 37 | WipperSnapper_I2C_Driver_TSL2591(TwoWire *i2c, uint16_t sensorAddress) 38 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 39 | _i2c = i2c; 40 | _sensorAddress = sensorAddress; 41 | } 42 | 43 | /*******************************************************************************/ 44 | /*! 45 | @brief Destructor for an TSL2591 sensor. 46 | */ 47 | /*******************************************************************************/ 48 | ~WipperSnapper_I2C_Driver_TSL2591() { delete _tsl; } 49 | 50 | /*******************************************************************************/ 51 | /*! 52 | @brief Initializes the TSL2591 sensor and begins I2C. 53 | @returns True if initialized successfully, False otherwise. 54 | */ 55 | /*******************************************************************************/ 56 | bool begin() { 57 | _tsl = new Adafruit_TSL2591(2591); 58 | // Attempt to initialize TSL2591 59 | if (!_tsl->begin(_i2c, TSL2591_ADDR)) 60 | return false; 61 | 62 | // Configure TSL2591 sensor 63 | // Note: This driver uses the default configuration from 64 | // https://github.com/adafruit/Adafruit_TSL2591_Library/blob/master/examples/tsl2591/tsl2591.ino 65 | _tsl->setGain(TSL2591_GAIN_MED); // 25x gain 66 | _tsl->setTiming(TSL2591_INTEGRATIONTIME_300MS); // 300ms integration time 67 | return true; 68 | } 69 | 70 | /*******************************************************************************/ 71 | /*! 72 | @brief Performs a light sensor read using the Adafruit 73 | Unified Sensor API. 74 | @param lightEvent 75 | Light sensor reading, in lux. 76 | @returns True if the sensor event was obtained successfully, False 77 | otherwise. 78 | */ 79 | /*******************************************************************************/ 80 | bool getEventLight(sensors_event_t *lightEvent) { 81 | // Get sensor event 82 | _tsl->getEvent(lightEvent); 83 | 84 | // If lightEvent->light = 0 lux the sensor is probably saturated and no 85 | // reliable data could be generated! or if lightEvent->light is +/- 86 | // 4294967040 there was a float over/underflow 87 | if ((lightEvent->light == 0) | (lightEvent->light > 4294966000.0) | 88 | (lightEvent->light < -4294966000.0)) 89 | return false; 90 | 91 | return true; 92 | } 93 | 94 | protected: 95 | Adafruit_TSL2591 *_tsl; ///< Pointer to TSL2591 light sensor object 96 | }; 97 | 98 | #endif // WipperSnapper_I2C_Driver_TSL2591 -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_SHT4X.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_SHT4X.h 3 | * 4 | * Device driver for the SHT4X Temperature and Humidity Sensor 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Marni Brewster 2022 for Adafruit Industries. 11 | * Copyright (c) Tyeth Gundry 2022. Original code by Marni, 12 | * rewritten to use driver by Sensirion, help from Brent Rubell. 13 | * 14 | * MIT license, all text here must be included in any redistribution. 15 | * 16 | */ 17 | 18 | #ifndef WipperSnapper_I2C_Driver_SHT4X_H 19 | #define WipperSnapper_I2C_Driver_SHT4X_H 20 | 21 | #include "WipperSnapper_I2C_Driver.h" 22 | #include 23 | #include 24 | 25 | /**************************************************************************/ 26 | /*! 27 | @brief Class that provides a driver interface for the SHT4X sensor. 28 | */ 29 | /**************************************************************************/ 30 | class WipperSnapper_I2C_Driver_SHT4X : public WipperSnapper_I2C_Driver { 31 | 32 | public: 33 | /*******************************************************************************/ 34 | /*! 35 | @brief Constructor for a SHT4X sensor. 36 | @param i2c 37 | The I2C interface. 38 | @param sensorAddress 39 | 7-bit device address. 40 | */ 41 | /*******************************************************************************/ 42 | WipperSnapper_I2C_Driver_SHT4X(TwoWire *i2c, uint16_t sensorAddress) 43 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 44 | _i2c = i2c; 45 | _sensorAddress = sensorAddress; 46 | } 47 | 48 | /*******************************************************************************/ 49 | /*! 50 | @brief Initializes the SHT4X sensor and begins I2C. 51 | @returns True if initialized successfully, False otherwise. 52 | */ 53 | /*******************************************************************************/ 54 | bool begin() { 55 | _sht4x = new SHTSensor(SHTSensor::SHT4X); 56 | if (!_sht4x->init(*_i2c)) 57 | return false; 58 | 59 | // configure SHT4x sensor 60 | _sht4x->setAccuracy(SHTSensor::SHT_ACCURACY_HIGH); 61 | 62 | return true; 63 | } 64 | 65 | /*******************************************************************************/ 66 | /*! 67 | @brief Gets the SHT4X's current temperature. 68 | @param tempEvent 69 | Pointer to an Adafruit_Sensor event. 70 | @returns True if the temperature was obtained successfully, False 71 | otherwise. 72 | */ 73 | /*******************************************************************************/ 74 | bool getEventAmbientTemp(sensors_event_t *tempEvent) { 75 | // populate temp and humidity objects with fresh data 76 | if (!_sht4x->readSample()) 77 | return false; 78 | tempEvent->temperature = _sht4x->getTemperature(); 79 | return true; 80 | } 81 | 82 | /*******************************************************************************/ 83 | /*! 84 | @brief Gets the SHT4X's current relative humidity reading. 85 | @param humidEvent 86 | Pointer to an Adafruit_Sensor event. 87 | @returns True if the humidity was obtained successfully, False 88 | otherwise. 89 | */ 90 | /*******************************************************************************/ 91 | bool getEventRelativeHumidity(sensors_event_t *humidEvent) { 92 | // populate temp and humidity objects with fresh data 93 | if (!_sht4x->readSample()) 94 | return false; 95 | humidEvent->relative_humidity = _sht4x->getHumidity(); 96 | return true; 97 | } 98 | 99 | protected: 100 | SHTSensor *_sht4x; ///< SHT4X object 101 | }; 102 | 103 | #endif // WipperSnapper_I2C_Driver_SHT4X -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_INA219.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_INA219.h 3 | * 4 | * Device driver for the INA219 High-side DC Current and Voltage Monitor 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Tyeth Gundry 2023 for Adafruit Industries. 11 | * 12 | * MIT license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | #ifndef WipperSnapper_I2C_Driver_INA219_H 16 | #define WipperSnapper_I2C_Driver_INA219_H 17 | 18 | #include "WipperSnapper_I2C_Driver.h" 19 | #include 20 | 21 | /**************************************************************************/ 22 | /*! 23 | @brief Class that provides a driver interface for a INA219 sensor. 24 | */ 25 | /**************************************************************************/ 26 | class WipperSnapper_I2C_Driver_INA219 : public WipperSnapper_I2C_Driver { 27 | public: 28 | /*******************************************************************************/ 29 | /*! 30 | @brief Constructor for a INA219 sensor. 31 | @param i2c 32 | The I2C interface. 33 | @param sensorAddress 34 | The 7-bit I2C address of the sensor. 35 | */ 36 | /*******************************************************************************/ 37 | WipperSnapper_I2C_Driver_INA219(TwoWire *i2c, uint16_t sensorAddress) 38 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 39 | _i2c = i2c; 40 | _sensorAddress = sensorAddress; 41 | } 42 | 43 | /*******************************************************************************/ 44 | /*! 45 | @brief Destructor for an INA219 sensor. 46 | */ 47 | /*******************************************************************************/ 48 | ~WipperSnapper_I2C_Driver_INA219() { delete _ina219; } 49 | 50 | /*******************************************************************************/ 51 | /*! 52 | @brief Initializes the INA219 sensor and begins I2C. 53 | @returns True if initialized successfully, False otherwise. 54 | */ 55 | /*******************************************************************************/ 56 | bool begin() { 57 | _ina219 = new Adafruit_INA219(_sensorAddress); 58 | if (!_ina219->begin(_i2c)) 59 | return false; 60 | 61 | // TODO: use setCalibration() 62 | 63 | return true; 64 | } 65 | 66 | /*******************************************************************************/ 67 | /*! 68 | @brief Reads a voltage sensor and converts the 69 | reading into the expected SI unit. 70 | @param voltageEvent 71 | voltage sensor reading, in volts. 72 | @returns True if the sensor event was obtained successfully, False 73 | otherwise. 74 | */ 75 | /*******************************************************************************/ 76 | bool getEventVoltage(sensors_event_t *voltageEvent) { 77 | float shuntvoltage_mV = _ina219->getShuntVoltage_mV(); 78 | float busvoltage_V = _ina219->getBusVoltage_V(); 79 | 80 | // Compute load voltage 81 | float loadvoltage = busvoltage_V + (shuntvoltage_mV / 1000); 82 | voltageEvent->voltage = loadvoltage; 83 | return true; 84 | } 85 | 86 | /** 87 | * @brief Get the current sensor event. 88 | * 89 | * @param currentEvent Pointer to the current sensor event. 90 | * 91 | * @returns True if the sensor event was obtained successfully, False 92 | * otherwise. 93 | */ 94 | bool getEventCurrent(sensors_event_t *currentEvent) { 95 | float current_mA = _ina219->getCurrent_mA(); 96 | currentEvent->current = current_mA; 97 | return true; 98 | } 99 | 100 | protected: 101 | Adafruit_INA219 *_ina219; ///< Pointer to INA219 sensor object 102 | }; 103 | 104 | #endif // WipperSnapper_I2C_Driver_INA219 -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_MPL115A2.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_MPL115A2.h 3 | * 4 | * Device driver for a MPL115A2 pressure sensor breakout. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Tyeth Gundry 2023 for Adafruit Industries. 11 | * 12 | * MIT license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | 16 | #ifndef WipperSnapper_I2C_Driver_MPL115A2_H 17 | #define WipperSnapper_I2C_Driver_MPL115A2_H 18 | 19 | #include "WipperSnapper_I2C_Driver.h" 20 | #include 21 | 22 | /**************************************************************************/ 23 | /*! 24 | @brief Class that provides a sensor driver for the MPL115A2 temperature 25 | and pressure sensor. 26 | */ 27 | /**************************************************************************/ 28 | class WipperSnapper_I2C_Driver_MPL115A2 : public WipperSnapper_I2C_Driver { 29 | 30 | public: 31 | /*******************************************************************************/ 32 | /*! 33 | @brief Constructor for an MPL115A2 sensor. 34 | @param i2c 35 | The I2C interface. 36 | @param sensorAddress 37 | 7-bit device address. 38 | */ 39 | /*******************************************************************************/ 40 | WipperSnapper_I2C_Driver_MPL115A2(TwoWire *i2c, uint16_t sensorAddress) 41 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 42 | _i2c = i2c; 43 | _sensorAddress = sensorAddress; 44 | } 45 | 46 | /*******************************************************************************/ 47 | /*! 48 | @brief Destructor for an MPL115A2 sensor. 49 | */ 50 | /*******************************************************************************/ 51 | ~WipperSnapper_I2C_Driver_MPL115A2() { delete _mpl115a2; } 52 | 53 | /*******************************************************************************/ 54 | /*! 55 | @brief Initializes the MPL115A2 sensor and begins I2C. 56 | @returns True if initialized successfully, False otherwise. 57 | */ 58 | /*******************************************************************************/ 59 | bool begin() { 60 | _mpl115a2 = new Adafruit_MPL115A2(); 61 | // attempt to initialize MPL115A2 62 | if (!_mpl115a2->begin(_sensorAddress, _i2c)) 63 | return false; 64 | return true; 65 | } 66 | 67 | /*******************************************************************************/ 68 | /*! 69 | @brief Gets the MPL115A2's current temperature. 70 | @param tempEvent 71 | Pointer to an Adafruit_Sensor event. 72 | @returns True if the temperature was obtained successfully, False 73 | otherwise. 74 | */ 75 | /*******************************************************************************/ 76 | bool getEventAmbientTemp(sensors_event_t *tempEvent) { 77 | tempEvent->temperature = _mpl115a2->getTemperature(); 78 | return true; 79 | } 80 | 81 | /*******************************************************************************/ 82 | /*! 83 | @brief Reads a pressure sensor and converts 84 | the reading into the expected SI unit (hPa). 85 | @param pressureEvent 86 | Pointer to an Adafruit_Sensor event. 87 | @returns True if the sensor event was obtained successfully, False 88 | otherwise. 89 | */ 90 | /*******************************************************************************/ 91 | bool getEventPressure(sensors_event_t *pressureEvent) { 92 | pressureEvent->pressure = _mpl115a2->getPressure() * 10; 93 | return true; 94 | } 95 | 96 | protected: 97 | Adafruit_MPL115A2 *_mpl115a2; ///< MPL115A2 object 98 | }; 99 | 100 | #endif // WipperSnapper_I2C_Driver_MPL115A2 -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_INA228.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_INA228.cpp 3 | * 4 | * Device driver implementation for the INA228 High Precision DC Current and 5 | * Voltage Monitor (Avoids import conflict with INA260 typedef enum _mode etc) 6 | * 7 | * Adafruit invests time and resources providing this open source code, 8 | * please support Adafruit and open-source hardware by purchasing 9 | * products from Adafruit! 10 | * 11 | * Copyright (c) Tyeth Gundry 2025 for Adafruit Industries. 12 | * 13 | * MIT license, all text here must be included in any redistribution. 14 | * 15 | */ 16 | 17 | #include "WipperSnapper_I2C_Driver_INA228.h" 18 | #include "Wippersnapper.h" 19 | #include 20 | 21 | /*******************************************************************************/ 22 | /*! 23 | @brief Constructor for a INA228 sensor. 24 | @param i2c 25 | The I2C interface. 26 | @param sensorAddress 27 | The 7-bit I2C address of the sensor. 28 | */ 29 | /*******************************************************************************/ 30 | WipperSnapper_I2C_Driver_INA228::WipperSnapper_I2C_Driver_INA228( 31 | TwoWire *i2c, uint16_t sensorAddress) 32 | : WipperSnapper_I2C_Driver(i2c, sensorAddress), _ina228(nullptr) { 33 | _i2c = i2c; 34 | _sensorAddress = sensorAddress; 35 | } 36 | 37 | /*******************************************************************************/ 38 | /*! 39 | @brief Destructor for an INA228 sensor. 40 | */ 41 | /*******************************************************************************/ 42 | WipperSnapper_I2C_Driver_INA228::~WipperSnapper_I2C_Driver_INA228() { 43 | delete _ina228; 44 | } 45 | 46 | /*******************************************************************************/ 47 | /*! 48 | @brief Initializes the INA228 sensor and begins I2C. 49 | @returns True if initialized successfully, False otherwise. 50 | */ 51 | /*******************************************************************************/ 52 | bool WipperSnapper_I2C_Driver_INA228::begin() { 53 | _ina228 = new Adafruit_INA228(); 54 | if (!_ina228->begin(_sensorAddress, _i2c)) { 55 | return false; 56 | } 57 | 58 | // Default shunt: 0.015 ohm, 10A max current 59 | _ina228->setShunt(0.015, 10.0); 60 | 61 | _ina228->setAveragingCount(INA228_COUNT_16); 62 | _ina228->setVoltageConversionTime(INA228_TIME_150_us); 63 | _ina228->setCurrentConversionTime(INA228_TIME_280_us); 64 | 65 | return true; 66 | } 67 | 68 | /*******************************************************************************/ 69 | /*! 70 | @brief Reads a voltage sensor and converts the 71 | reading into the expected SI unit. 72 | @param voltageEvent 73 | voltage sensor reading, in volts. 74 | @returns True if the sensor event was obtained successfully, False 75 | otherwise. 76 | */ 77 | /*******************************************************************************/ 78 | bool WipperSnapper_I2C_Driver_INA228::getEventVoltage( 79 | sensors_event_t *voltageEvent) { 80 | voltageEvent->voltage = _ina228->getBusVoltage_V(); 81 | return true; 82 | } 83 | 84 | /** 85 | * @brief Get the current sensor event. 86 | * 87 | * @param currentEvent Pointer to the current sensor event. 88 | * 89 | * @returns True if the sensor event was obtained successfully, False 90 | * otherwise. 91 | */ 92 | bool WipperSnapper_I2C_Driver_INA228::getEventCurrent( 93 | sensors_event_t *currentEvent) { 94 | currentEvent->current = _ina228->getCurrent_mA(); 95 | return true; 96 | } 97 | 98 | /** 99 | * @brief Get the raw (power) sensor event. 100 | * 101 | * @param powerEvent Pointer to the power sensor event. 102 | * 103 | * @returns True if the sensor event was obtained successfully, False 104 | * otherwise. 105 | */ 106 | bool WipperSnapper_I2C_Driver_INA228::getEventRaw(sensors_event_t *powerEvent) { 107 | powerEvent->data[0] = _ina228->getPower_mW(); 108 | return true; 109 | } 110 | -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_SI7021.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_SI7021.h 3 | * 4 | * Device driver for the SI7021 Temperature, and Humidity sensor. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Tyeth Gundry 2022 for Adafruit Industries. 11 | * Copyright (c) Marni Brewster 2022 for Adafruit Industries. 12 | * 13 | * MIT license, all text here must be included in any redistribution. 14 | * 15 | */ 16 | 17 | #ifndef WipperSnapper_I2C_Driver_SI7021_H 18 | #define WipperSnapper_I2C_Driver_SI7021_H 19 | 20 | #include "WipperSnapper_I2C_Driver.h" 21 | #include 22 | #include 23 | 24 | /**************************************************************************/ 25 | /*! 26 | @brief Class that provides a driver interface for the SI7021 sensor. 27 | */ 28 | /**************************************************************************/ 29 | class WipperSnapper_I2C_Driver_SI7021 : public WipperSnapper_I2C_Driver { 30 | 31 | public: 32 | /*******************************************************************************/ 33 | /*! 34 | @brief Constructor for a SI7021 sensor. 35 | @param i2c 36 | The I2C interface. 37 | @param sensorAddress 38 | 7-bit device address. 39 | */ 40 | /*******************************************************************************/ 41 | WipperSnapper_I2C_Driver_SI7021(TwoWire *i2c, uint16_t sensorAddress) 42 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 43 | _i2c = i2c; 44 | _sensorAddress = sensorAddress; 45 | } 46 | 47 | /*******************************************************************************/ 48 | /*! 49 | @brief Destructor for an SI7021 sensor. 50 | */ 51 | /*******************************************************************************/ 52 | ~WipperSnapper_I2C_Driver_SI7021() { 53 | // Called when a Si7021 component is deleted. 54 | delete _si7021; 55 | } 56 | 57 | /*******************************************************************************/ 58 | /*! 59 | @brief Initializes the SI7021 sensor and begins I2C. 60 | @returns True if initialized successfully, False otherwise. 61 | */ 62 | /*******************************************************************************/ 63 | bool begin() { 64 | _si7021 = new Adafruit_Si7021(_i2c); 65 | return _si7021->begin(); 66 | } 67 | 68 | /*******************************************************************************/ 69 | /*! 70 | @brief Gets the SI7021's current temperature. 71 | @param tempEvent 72 | Pointer to an Adafruit_Sensor event. 73 | @returns True if the temperature was obtained successfully, False 74 | otherwise. 75 | */ 76 | /*******************************************************************************/ 77 | bool getEventAmbientTemp(sensors_event_t *tempEvent) { 78 | // check if sensor is enabled and data is available 79 | tempEvent->temperature = _si7021->readTemperature(); 80 | return true; 81 | } 82 | 83 | /*******************************************************************************/ 84 | /*! 85 | @brief Gets the SI7021's current relative humidity reading. 86 | @param humidEvent 87 | Pointer to an Adafruit_Sensor event. 88 | @returns True if the humidity was obtained successfully, False 89 | otherwise. 90 | */ 91 | /*******************************************************************************/ 92 | bool getEventRelativeHumidity(sensors_event_t *humidEvent) { 93 | // check if sensor is enabled and data is available 94 | humidEvent->relative_humidity = _si7021->readHumidity(); 95 | return true; 96 | } 97 | 98 | protected: 99 | Adafruit_Si7021 *_si7021; ///< SI7021 driver object 100 | }; 101 | 102 | #endif // WipperSnapper_I2C_Driver_SI7021 -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_SHT3X.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_SHT3X.h 3 | * 4 | * Device driver for the SHT3X Temperature and Humidity Sensor 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Marni Brewster 2022 for Adafruit Industries. 11 | * Copyright (c) Tyeth Gundry 2022. Original code by Marni, 12 | * rewritten to use driver by Sensirion, help from Brent Rubell. 13 | * 14 | * MIT license, all text here must be included in any redistribution. 15 | * 16 | */ 17 | 18 | #ifndef WipperSnapper_I2C_Driver_SHT3X_H 19 | #define WipperSnapper_I2C_Driver_SHT3X_H 20 | 21 | #include "WipperSnapper_I2C_Driver.h" 22 | #include 23 | #include 24 | 25 | /**************************************************************************/ 26 | /*! 27 | @brief Class that provides a driver interface for the SHT3X sensor. 28 | */ 29 | /**************************************************************************/ 30 | class WipperSnapper_I2C_Driver_SHT3X : public WipperSnapper_I2C_Driver { 31 | 32 | public: 33 | /*******************************************************************************/ 34 | /*! 35 | @brief Constructor for a SHT3X sensor. 36 | @param i2c 37 | The I2C interface. 38 | @param sensorAddress 39 | 7-bit device address. 40 | */ 41 | /*******************************************************************************/ 42 | WipperSnapper_I2C_Driver_SHT3X(TwoWire *i2c, uint16_t sensorAddress) 43 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 44 | _i2c = i2c; 45 | _sensorAddress = sensorAddress; 46 | } 47 | 48 | /*******************************************************************************/ 49 | /*! 50 | @brief Initializes the SHT3X sensor and begins I2C. 51 | @returns True if initialized successfully, False otherwise. 52 | */ 53 | /*******************************************************************************/ 54 | bool begin() { 55 | if (_sensorAddress == 0x44) // if address 0x44 (dec:68), alternative = 0x45 56 | _sht3x = new SHTSensor(SHTSensor::SHT3X); 57 | else 58 | _sht3x = new SHTSensor(SHTSensor::SHT3X_ALT); 59 | 60 | if (!_sht3x->init(*_i2c)) 61 | return false; 62 | 63 | // Use HIGH PRECISION - only supported by 3X/4X 64 | return _sht3x->setAccuracy(SHTSensor::SHT_ACCURACY_HIGH); 65 | } 66 | 67 | /*******************************************************************************/ 68 | /*! 69 | @brief Gets the SHT3X's current temperature. 70 | @param tempEvent 71 | Pointer to an Adafruit_Sensor event. 72 | @returns True if the temperature was obtained successfully, False 73 | otherwise. 74 | */ 75 | /*******************************************************************************/ 76 | bool getEventAmbientTemp(sensors_event_t *tempEvent) { 77 | // populate temp and humidity objects with fresh data 78 | if (!_sht3x->readSample()) 79 | return false; 80 | tempEvent->temperature = _sht3x->getTemperature(); 81 | return true; 82 | } 83 | 84 | /*******************************************************************************/ 85 | /*! 86 | @brief Gets the SHT3X's current relative humidity reading. 87 | @param humidEvent 88 | Pointer to an Adafruit_Sensor event. 89 | @returns True if the humidity was obtained successfully, False 90 | otherwise. 91 | */ 92 | /*******************************************************************************/ 93 | bool getEventRelativeHumidity(sensors_event_t *humidEvent) { 94 | // populate temp and humidity objects with fresh data 95 | if (!_sht3x->readSample()) 96 | return false; 97 | humidEvent->relative_humidity = _sht3x->getHumidity(); 98 | return true; 99 | } 100 | 101 | protected: 102 | SHTSensor *_sht3x; ///< SHT3X object 103 | }; 104 | 105 | #endif // WipperSnapper_I2C_Driver_SHT3X -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_LPS3XHW.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_LPS3XHW.h 3 | * 4 | * Device driver for a LPS3XHW precision pressure sensor breakout. 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Tyeth Gundry 2023 for Adafruit Industries. 11 | * 12 | * MIT license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | 16 | #ifndef WipperSnapper_I2C_Driver_LPS3XHW_H 17 | #define WipperSnapper_I2C_Driver_LPS3XHW_H 18 | 19 | #include "WipperSnapper_I2C_Driver.h" 20 | #include 21 | 22 | /**************************************************************************/ 23 | /*! 24 | @brief Class that provides a sensor driver for the LPS3XHW temperature 25 | and pressure sensor. 26 | */ 27 | /**************************************************************************/ 28 | class WipperSnapper_I2C_Driver_LPS3XHW : public WipperSnapper_I2C_Driver { 29 | 30 | public: 31 | /*******************************************************************************/ 32 | /*! 33 | @brief Constructor for an LPS3XHW sensor. 34 | @param i2c 35 | The I2C interface. 36 | @param sensorAddress 37 | 7-bit device address. 38 | */ 39 | /*******************************************************************************/ 40 | WipperSnapper_I2C_Driver_LPS3XHW(TwoWire *i2c, uint16_t sensorAddress) 41 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 42 | _i2c = i2c; 43 | _sensorAddress = sensorAddress; 44 | } 45 | 46 | /*******************************************************************************/ 47 | /*! 48 | @brief Destructor for an LPS3XHW sensor. 49 | */ 50 | /*******************************************************************************/ 51 | ~WipperSnapper_I2C_Driver_LPS3XHW() { delete _lps3xhw; } 52 | 53 | /*******************************************************************************/ 54 | /*! 55 | @brief Initializes the LPS3XHW sensor and begins I2C. 56 | @returns True if initialized successfully, False otherwise. 57 | */ 58 | /*******************************************************************************/ 59 | bool begin() { 60 | _lps3xhw = new Adafruit_LPS35HW(); 61 | // attempt to initialize LPS3XHW 62 | if (!_lps3xhw->begin_I2C(_sensorAddress, _i2c)) 63 | return false; 64 | 65 | // Set up sample rate and filter initialization 66 | _lps3xhw->setDataRate(LPS35HW_RATE_ONE_SHOT); 67 | _lps3xhw->enableLowPass(); 68 | 69 | return true; 70 | } 71 | 72 | /*******************************************************************************/ 73 | /*! 74 | @brief Gets the LPS3XHW's current temperature. 75 | @param tempEvent 76 | Pointer to an Adafruit_Sensor event. 77 | @returns True if the temperature was obtained successfully, False 78 | otherwise. 79 | */ 80 | /*******************************************************************************/ 81 | bool getEventAmbientTemp(sensors_event_t *tempEvent) { 82 | _lps3xhw->takeMeasurement(); 83 | tempEvent->temperature = _lps3xhw->readTemperature(); 84 | return true; 85 | } 86 | 87 | /*******************************************************************************/ 88 | /*! 89 | @brief Reads a pressure sensor and converts 90 | the reading into the expected SI unit. 91 | @param pressureEvent 92 | Pointer to an Adafruit_Sensor event. 93 | @returns True if the sensor event was obtained successfully, False 94 | otherwise. 95 | */ 96 | /*******************************************************************************/ 97 | bool getEventPressure(sensors_event_t *pressureEvent) { 98 | _lps3xhw->takeMeasurement(); 99 | pressureEvent->pressure = _lps3xhw->readPressure(); 100 | return true; 101 | } 102 | 103 | protected: 104 | Adafruit_LPS35HW *_lps3xhw; ///< LPS3XHW object 105 | }; 106 | 107 | #endif // WipperSnapper_I2C_Driver_LPS3XHW -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_INA237.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_INA237.cpp 3 | * 4 | * Device driver implementation for the INA237 DC Current and Voltage Monitor 5 | * (Avoids import conflict with INA260 typedef enum _mode etc) 6 | * 7 | * Adafruit invests time and resources providing this open source code, 8 | * please support Adafruit and open-source hardware by purchasing 9 | * products from Adafruit! 10 | * 11 | * Copyright (c) Tyeth Gundry 2025 for Adafruit Industries. 12 | * 13 | * MIT license, all text here must be included in any redistribution. 14 | * 15 | */ 16 | 17 | #include "WipperSnapper_I2C_Driver_INA237.h" 18 | #include "Wippersnapper.h" 19 | #include 20 | 21 | /*******************************************************************************/ 22 | /*! 23 | @brief Constructor for a INA237 sensor. 24 | @param i2c 25 | The I2C interface. 26 | @param sensorAddress 27 | The 7-bit I2C address of the sensor. 28 | */ 29 | /*******************************************************************************/ 30 | WipperSnapper_I2C_Driver_INA237::WipperSnapper_I2C_Driver_INA237( 31 | TwoWire *i2c, uint16_t sensorAddress) 32 | : WipperSnapper_I2C_Driver(i2c, sensorAddress), _ina237(nullptr) { 33 | _i2c = i2c; 34 | _sensorAddress = sensorAddress; 35 | } 36 | 37 | /*******************************************************************************/ 38 | /*! 39 | @brief Destructor for an INA237 sensor. 40 | */ 41 | /*******************************************************************************/ 42 | WipperSnapper_I2C_Driver_INA237::~WipperSnapper_I2C_Driver_INA237() { 43 | delete _ina237; 44 | } 45 | 46 | /*******************************************************************************/ 47 | /*! 48 | @brief Initializes the INA237 sensor and begins I2C. 49 | @returns True if initialized successfully, False otherwise. 50 | */ 51 | /*******************************************************************************/ 52 | bool WipperSnapper_I2C_Driver_INA237::begin() { 53 | _ina237 = new Adafruit_INA237(); 54 | if (!_ina237->begin(_sensorAddress, _i2c)) { 55 | return false; 56 | } 57 | 58 | // Configuration based on INA237 example sketch 59 | // Set default shunt resistance and maximum current 60 | // Default 0.015 ohm shunt, 10A max current 61 | _ina237->setShunt(0.015, 10.0); 62 | 63 | // Set averaging for better accuracy (16 samples) 64 | _ina237->setAveragingCount(INA2XX_COUNT_16); 65 | 66 | // Set conversion times as per example 67 | _ina237->setVoltageConversionTime(INA2XX_TIME_150_us); 68 | _ina237->setCurrentConversionTime(INA2XX_TIME_280_us); 69 | 70 | return true; 71 | } 72 | 73 | /*******************************************************************************/ 74 | /*! 75 | @brief Reads a voltage sensor and converts the 76 | reading into the expected SI unit. 77 | @param voltageEvent 78 | voltage sensor reading, in volts. 79 | @returns True if the sensor event was obtained successfully, False 80 | otherwise. 81 | */ 82 | /*******************************************************************************/ 83 | bool WipperSnapper_I2C_Driver_INA237::getEventVoltage( 84 | sensors_event_t *voltageEvent) { 85 | voltageEvent->voltage = _ina237->getBusVoltage_V(); 86 | return true; 87 | } 88 | 89 | /** 90 | * @brief Get the current sensor event. 91 | * 92 | * @param currentEvent Pointer to the current sensor event. 93 | * 94 | * @returns True if the sensor event was obtained successfully, False 95 | * otherwise. 96 | */ 97 | bool WipperSnapper_I2C_Driver_INA237::getEventCurrent( 98 | sensors_event_t *currentEvent) { 99 | currentEvent->current = _ina237->getCurrent_mA(); 100 | return true; 101 | } 102 | 103 | /** 104 | * @brief Get the raw (power) sensor event. 105 | * 106 | * @param powerEvent Pointer to the power sensor event. 107 | * 108 | * @returns True if the sensor event was obtained successfully, False 109 | * otherwise. 110 | */ 111 | bool WipperSnapper_I2C_Driver_INA237::getEventRaw(sensors_event_t *powerEvent) { 112 | powerEvent->data[0] = _ina237->getPower_mW(); 113 | return true; 114 | } -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_INA238.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_INA238.cpp 3 | * 4 | * Device driver implementation for the INA238 High-precision DC Current and 5 | * Voltage Monitor (Avoids import conflict with INA260 typedef enum _mode etc) 6 | * 7 | * Adafruit invests time and resources providing this open source code, 8 | * please support Adafruit and open-source hardware by purchasing 9 | * products from Adafruit! 10 | * 11 | * Copyright (c) Tyeth Gundry 2025 for Adafruit Industries. 12 | * 13 | * MIT license, all text here must be included in any redistribution. 14 | * 15 | */ 16 | 17 | #include "WipperSnapper_I2C_Driver_INA238.h" 18 | #include "Wippersnapper.h" 19 | #include 20 | 21 | /*******************************************************************************/ 22 | /*! 23 | @brief Constructor for a INA238 sensor. 24 | @param i2c 25 | The I2C interface. 26 | @param sensorAddress 27 | The 7-bit I2C address of the sensor. 28 | */ 29 | /*******************************************************************************/ 30 | WipperSnapper_I2C_Driver_INA238::WipperSnapper_I2C_Driver_INA238( 31 | TwoWire *i2c, uint16_t sensorAddress) 32 | : WipperSnapper_I2C_Driver(i2c, sensorAddress), _ina238(nullptr) { 33 | _i2c = i2c; 34 | _sensorAddress = sensorAddress; 35 | } 36 | 37 | /*******************************************************************************/ 38 | /*! 39 | @brief Destructor for an INA238 sensor. 40 | */ 41 | /*******************************************************************************/ 42 | WipperSnapper_I2C_Driver_INA238::~WipperSnapper_I2C_Driver_INA238() { 43 | delete _ina238; 44 | } 45 | 46 | /*******************************************************************************/ 47 | /*! 48 | @brief Initializes the INA238 sensor and begins I2C. 49 | @returns True if initialized successfully, False otherwise. 50 | */ 51 | /*******************************************************************************/ 52 | bool WipperSnapper_I2C_Driver_INA238::begin() { 53 | _ina238 = new Adafruit_INA238(); 54 | if (!_ina238->begin(_sensorAddress, _i2c)) { 55 | return false; 56 | } 57 | 58 | // Configuration based on INA238 example sketch 59 | // Set default shunt resistance and maximum current 60 | // Default 0.015 ohm shunt, 10A max current 61 | _ina238->setShunt(0.015, 10.0); 62 | 63 | // Set averaging for better accuracy (16 samples) 64 | _ina238->setAveragingCount(INA2XX_COUNT_16); 65 | 66 | // Set conversion times as per example 67 | _ina238->setVoltageConversionTime(INA2XX_TIME_150_us); 68 | _ina238->setCurrentConversionTime(INA2XX_TIME_280_us); 69 | 70 | return true; 71 | } 72 | 73 | /*******************************************************************************/ 74 | /*! 75 | @brief Reads a voltage sensor and converts the 76 | reading into the expected SI unit. 77 | @param voltageEvent 78 | voltage sensor reading, in volts. 79 | @returns True if the sensor event was obtained successfully, False 80 | otherwise. 81 | */ 82 | /*******************************************************************************/ 83 | bool WipperSnapper_I2C_Driver_INA238::getEventVoltage( 84 | sensors_event_t *voltageEvent) { 85 | voltageEvent->voltage = _ina238->getBusVoltage_V(); 86 | return true; 87 | } 88 | 89 | /** 90 | * @brief Get the current sensor event. 91 | * 92 | * @param currentEvent Pointer to the current sensor event. 93 | * 94 | * @returns True if the sensor event was obtained successfully, False 95 | * otherwise. 96 | */ 97 | bool WipperSnapper_I2C_Driver_INA238::getEventCurrent( 98 | sensors_event_t *currentEvent) { 99 | currentEvent->current = _ina238->getCurrent_mA(); 100 | return true; 101 | } 102 | 103 | /** 104 | * @brief Get the Raw (power) sensor event. 105 | * 106 | * @param powerEvent Pointer to the power sensor event. 107 | * 108 | * @returns True if the sensor event was obtained successfully, False 109 | * otherwise. 110 | */ 111 | bool WipperSnapper_I2C_Driver_INA238::getEventRaw(sensors_event_t *powerEvent) { 112 | powerEvent->data[0] = _ina238->getPower_mW(); 113 | return true; 114 | } -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_STEMMA_Soil_Sensor.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_STEMMA_Soil_Sensor.h 3 | * 4 | * Device driver for the STEMMA Soil Sensor 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit and open-source hardware by purchasing 8 | * products from Adafruit! 9 | * 10 | * Copyright (c) Marcus Wu 2022 11 | * 12 | * MIT license, all text here must be included in any redistribution. 13 | * 14 | */ 15 | 16 | #ifndef WipperSnapper_I2C_Driver_STEMMA_Soil_Sensor_H 17 | #define WipperSnapper_I2C_Driver_STEMMA_Soil_Sensor_H 18 | 19 | #include "WipperSnapper_I2C_Driver.h" 20 | #include 21 | 22 | /**************************************************************************/ 23 | /*! 24 | @brief Class that provides a driver interface for the STEMMA soil sensor. 25 | */ 26 | /**************************************************************************/ 27 | class WipperSnapper_I2C_Driver_STEMMA_Soil_Sensor 28 | : public WipperSnapper_I2C_Driver { 29 | public: 30 | /*******************************************************************************/ 31 | /*! 32 | @brief Constructor for a STEMMA soil sensor. 33 | @param i2c 34 | The I2C interface. 35 | @param sensorAddress 36 | 7-bit device address. 37 | */ 38 | /*******************************************************************************/ 39 | WipperSnapper_I2C_Driver_STEMMA_Soil_Sensor(TwoWire *i2c, 40 | uint16_t sensorAddress) 41 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 42 | _i2c = i2c; 43 | _sensorAddress = sensorAddress; 44 | _seesaw = new Adafruit_seesaw(_i2c); 45 | } 46 | 47 | /*******************************************************************************/ 48 | /*! 49 | @brief Destructor for a STEMMA soil sensor. 50 | */ 51 | /*******************************************************************************/ 52 | ~WipperSnapper_I2C_Driver_STEMMA_Soil_Sensor() { _seesaw = nullptr; } 53 | 54 | /*******************************************************************************/ 55 | /*! 56 | @brief Initializes the soil sensor and begins I2C. 57 | @returns True if initialized successfully, False otherwise. 58 | */ 59 | /*******************************************************************************/ 60 | bool begin() { return _seesaw->begin(_sensorAddress); } 61 | 62 | /*******************************************************************************/ 63 | /*! 64 | @brief Gets the sensor's current temperature. 65 | @param tempEvent 66 | Pointer to an Adafruit_Sensor event. 67 | @returns True if the temperature was obtained successfully, False 68 | otherwise. 69 | */ 70 | /*******************************************************************************/ 71 | bool getEventAmbientTemp(sensors_event_t *tempEvent) { 72 | tempEvent->temperature = _seesaw->getTemp(); 73 | return true; 74 | } 75 | 76 | /*******************************************************************************/ 77 | /*! 78 | @brief Gets the sensor's current moisture sensor capacitance value. 79 | @param rawEvent 80 | Pointer to an Adafruit_Sensor event. 81 | @returns True if the temperature was obtained successfully, False 82 | otherwise. 83 | */ 84 | /*******************************************************************************/ 85 | bool getEventRaw(sensors_event_t *rawEvent) { 86 | uint16_t touchData = _seesaw->touchRead(0); 87 | 88 | // seesaw->touchRead() will return 65535 on a read error. See more at 89 | // https://github.com/adafruit/Adafruit_Seesaw/blob/master/Adafruit_seesaw.cpp 90 | if (touchData == 65535) { 91 | rawEvent->data[0] = NAN; 92 | } else { 93 | // TODO: Update this should we add a capacitive moisture type to 94 | // adafruit_sensor 95 | rawEvent->data[0] = (float)touchData; 96 | } 97 | return true; 98 | } 99 | 100 | protected: 101 | Adafruit_seesaw *_seesaw = nullptr; ///< Seesaw object 102 | }; 103 | 104 | #endif // WipperSnapper_I2C_Driver_STEMMA_Soil_Sensor_H -------------------------------------------------------------------------------- /src/components/i2c/drivers/WipperSnapper_I2C_Driver_HTS221.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file WipperSnapper_I2C_Driver_HTS221.h 3 | * 4 | * Device driver for an HTS221 Humidity and Temperature sensor. 5 | */ 6 | 7 | #ifndef WipperSnapper_I2C_Driver_HTS221_H 8 | #define WipperSnapper_I2C_Driver_HTS221_H 9 | 10 | #include "WipperSnapper_I2C_Driver.h" 11 | #include 12 | 13 | /**************************************************************************/ 14 | /*! 15 | @brief Class that provides a sensor driver for the HTS221 humidity and 16 | temperature sensor. This implementation uses the 1 Hz data rate. 17 | */ 18 | /**************************************************************************/ 19 | class WipperSnapper_I2C_Driver_HTS221 : public WipperSnapper_I2C_Driver { 20 | 21 | public: 22 | /*******************************************************************************/ 23 | /*! 24 | @brief Constructor for an HTS221 sensor. 25 | @param i2c 26 | The I2C interface. 27 | @param sensorAddress 28 | 7-bit device address. 29 | */ 30 | /*******************************************************************************/ 31 | WipperSnapper_I2C_Driver_HTS221(TwoWire *i2c, uint16_t sensorAddress) 32 | : WipperSnapper_I2C_Driver(i2c, sensorAddress) { 33 | _i2c = i2c; 34 | _sensorAddress = sensorAddress; 35 | } 36 | 37 | /*******************************************************************************/ 38 | /*! 39 | @brief Destructor for an HTS221 sensor. 40 | */ 41 | /*******************************************************************************/ 42 | ~WipperSnapper_I2C_Driver_HTS221() { delete _hts221; } 43 | 44 | /*******************************************************************************/ 45 | /*! 46 | @brief Initializes the HTS221 sensor and begins I2C. 47 | @returns True if initialized successfully, False otherwise. 48 | 49 | */ 50 | /*******************************************************************************/ 51 | bool begin() { 52 | // attempt to initialize the HTS221 using the I2C interface 53 | _hts221 = new Adafruit_HTS221(); 54 | if (!_hts221->begin_I2C(_sensorAddress, _i2c)) 55 | return false; 56 | 57 | // set the HTS221's data rate to 1 Hz 58 | _hts221->setDataRate(HTS221_RATE_1_HZ); 59 | 60 | // get temperature and humidity sensor 61 | _hts221_temp = _hts221->getTemperatureSensor(); 62 | _hts221_humidity = _hts221->getHumiditySensor(); 63 | 64 | return true; 65 | } 66 | 67 | /*******************************************************************************/ 68 | /*! 69 | @brief Gets the HTS221's current temperature. 70 | @param tempEvent 71 | Pointer to an Adafruit_Sensor event. 72 | @returns True if the temperature was obtained successfully, False 73 | otherwise. 74 | */ 75 | /*******************************************************************************/ 76 | bool getEventAmbientTemp(sensors_event_t *tempEvent) { 77 | // is sensor enabled correctly? 78 | if (_hts221_temp == NULL) 79 | return false; 80 | // get temperature and return status 81 | return _hts221_temp->getEvent(tempEvent); 82 | } 83 | 84 | /*******************************************************************************/ 85 | /*! 86 | @brief Gets the HTS221's current humidity. 87 | @param humidEvent 88 | Pointer to an Adafruit_Sensor event. 89 | @returns True if the humidity was obtained successfully, False 90 | otherwise. 91 | */ 92 | /*******************************************************************************/ 93 | bool getEventRelativeHumidity(sensors_event_t *humidEvent) { 94 | // is sensor enabled correctly? 95 | if (_hts221_humidity == NULL) 96 | return false; 97 | // get humidity and return status 98 | return _hts221_humidity->getEvent(humidEvent); 99 | } 100 | 101 | protected: 102 | Adafruit_HTS221 *_hts221; ///< Pointer to an HTS221 object 103 | Adafruit_Sensor *_hts221_temp = 104 | NULL; ///< Holds data for the HTS221's temperature sensor 105 | Adafruit_Sensor *_hts221_humidity = 106 | NULL; ///< Holds data for the HTS221's humidity sensor 107 | }; 108 | 109 | #endif // WipperSnapper_I2C_Driver_HTS221 --------------------------------------------------------------------------------