This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include "esp32/esp32_adc.h" | |
| #include "esp_adc_cal.h" | |
| #include "mgos.h" | |
| #include "mgos_adc.h" | |
| #include "mgos_system.h" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let MYADC = { | |
| cfg: ffi('int adc1_config_channel_atten(int, int)'), // that function must be in the SDK | |
| }; | |
| let db6 = 2; // whatever the numeric value for 6 dB is 2 | |
| MYADC.cfg(pin, db6); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typedef enum { | |
| ADC_ATTEN_DB_0 = 0, /*!<The input voltage of ADC will be reduced to about 1/1 */ | |
| ADC_ATTEN_DB_2_5 = 1, /*!<The input voltage of ADC will be reduced to about 1/1.34 */ | |
| ADC_ATTEN_DB_6 = 2, /*!<The input voltage of ADC will be reduced to about 1/2 */ | |
| ADC_ATTEN_DB_11 = 3, /*!<The input voltage of ADC will be reduced to about 1/3.6*/ | |
| ADC_ATTEN_MAX, | |
| } adc_atten_t; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bool mgos_adc_enable(int pin) { | |
| struct esp32_adc_channel_info *ci = esp32_adc_get_channel_info(pin); | |
| if (ci == NULL) return false; | |
| /* TODO(rojer): Allow changing? */ | |
| ci->atten = ADC_ATTEN_11db; | |
| return esp32_update_channel_settings(ci); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [{ | |
| "includePath": [ | |
| "${workspaceFolder}/**", | |
| "/your path/git/mongoose-os/", | |
| "/your path/git/esp-idf/", | |
| "/your path/git/mjs/" | |
| ] | |
| }] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [{ | |
| "C_Cpp.intelliSenseEngineFallback": "Enabled", | |
| "files.associations": { | |
| "mgos.h": "c" | |
| }, | |
| "C_Cpp.intelliSenseEngine": "Tag Parser" | |
| }] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var blueLEDOn = false; | |
| var pushbuttonCounter = 0; | |
| setInterval(function () { | |
| blueLEDOn = !blueLEDOn; | |
| LED3.write(blueLEDOn); | |
| }, 1000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.eclipse.paho.client.mqttv3.MqttClient; | |
| import org.eclipse.paho.client.mqttv3.MqttConnectOptions; | |
| import org.eclipse.paho.client.mqttv3.MqttException; | |
| import org.eclipse.paho.client.mqttv3.MqttMessage; | |
| import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; | |
| import org.eclipse.paho.client.mqttv3.MqttCallback; | |
| public class HelloMQTT implements MqttCallback { | |
| MqttClient client; | |
| private MqttConnectOptions conOpt; |
NewerOlder