Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed SDFileSystem
Revision 1:9a043ee174de, committed 2019-07-05
- Comitter:
- epremeaux
- Date:
- Fri Jul 05 04:52:18 2019 +0000
- Parent:
- 0:b471f7764d46
- Child:
- 2:17a5c34b3a79
- Commit message:
- cleaning up and organizing directories. added a few programs
Changed in this revision
--- a/01_Basics/Button_Interrupt.cpp Thu Jul 04 11:04:42 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-
-#ifdef COMPILE_Button_Interrupt
-
-
-InterruptIn button(USER_BUTTON);
-
-DigitalOut led(LED1);
-
-double delay = 0.5; // 500 ms
-
-void pressed()
-{
- delay = 0.1; // 100 ms
-}
-
-void released()
-{
- delay = 0.5; // 500 ms
-}
-
-int main()
-{
- // Assign functions to button
- button.fall(&pressed);
- button.rise(&released);
-
- while (1) {
- led = !led;
- wait(delay);
- }
-}
-
-#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/02_Digital/Button_Interrupt.cpp Fri Jul 05 04:52:18 2019 +0000
@@ -0,0 +1,33 @@
+
+#ifdef COMPILE_Button_Interrupt
+
+
+InterruptIn button(USER_BUTTON);
+
+DigitalOut led(LED1);
+
+double delay = 0.5; // 500 ms
+
+void pressed()
+{
+ delay = 0.1; // 100 ms
+}
+
+void released()
+{
+ delay = 0.5; // 500 ms
+}
+
+int main()
+{
+ // Assign functions to button
+ button.fall(&pressed);
+ button.rise(&released);
+
+ while (1) {
+ led = !led;
+ wait(delay);
+ }
+}
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/02_Digital/Debounce.cpp Fri Jul 05 04:52:18 2019 +0000
@@ -0,0 +1,42 @@
+#ifdef COMPILE_Debounce
+
+DigitalOut led1(LED1);
+
+InterruptIn button1(USER_BUTTON);
+volatile bool button1_pressed = false; // Used in the main loop
+volatile bool button1_enabled = true; // Used for debouncing
+Timeout button1_timeout; // Used for debouncing
+
+// Enables button when bouncing is over
+void button1_enabled_cb(void)
+{
+ button1_enabled = true;
+}
+
+// ISR handling button pressed event
+void button1_onpressed_cb(void)
+{
+ if (button1_enabled) { // Disabled while the button is bouncing
+ button1_enabled = false;
+ button1_pressed = true; // To be read by the main loop
+ button1_timeout.attach(callback(button1_enabled_cb), 0.3); // Debounce time 300 ms
+ }
+}
+
+int main()
+{
+ //button1.mode(PullUp); // Activate pull-up
+ button1.fall(callback(button1_onpressed_cb)); // Attach ISR to handle button press event
+
+ int idx = 0; // Just for printf below
+
+ while(1) {
+ if (button1_pressed) { // Set when button is pressed
+ button1_pressed = false;
+ printf("Button pressed %d\n", idx++);
+ led1 = !led1;
+ }
+ }
+}
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/03_Analog/ADC_Internal.cpp Fri Jul 05 04:52:18 2019 +0000
@@ -0,0 +1,28 @@
+#ifdef COMPILE_ADC_Internal
+
+/*
+ This basic example just shows how to read the ADC internal channels raw values.
+ Please look in the corresponding device reference manual for a complete
+ description of how to make a temperature sensor, VBat or Vref measurement.
+*/
+
+AnalogIn adc_temp(ADC_TEMP);
+AnalogIn adc_vref(ADC_VREF);
+AnalogIn adc_vbat(ADC_VBAT); // Warning: Not available on all devices
+
+DigitalOut led(LED1);
+
+int main()
+{
+ printf("\nSTM32 ADC internal channels reading example\n");
+ while(1) {
+ printf("ADC Temp = %f\n", adc_temp.read());
+ printf("ADC VRef = %f\n", adc_vref.read());
+ printf("ADC VBat = %f\n", adc_vbat.read());
+ printf("\033[3A");
+ led = !led;
+ wait(1.0);
+ }
+}
+
+#endif
--- a/buildOptions.h Thu Jul 04 11:04:42 2019 +0000 +++ b/buildOptions.h Fri Jul 05 04:52:18 2019 +0000 @@ -1,88 +1,122 @@ // uncomment only ONE file to build in the example set +// if there is no description, there is likely no code file yet. +// (feel free to support the project by adding one and issuing a pull request ;) + +// 01_Basics: +//#define COMPILE_Blink +//#define COMPILE_Button +//#define COMPILE_DigitalReadSerial +//#define COMPILE_Fade +//#define COMPILE_Analog_In // reads analog value, converts to voltage, set LED high or low, prints to terminal + + +// 02_Digital: +//#define COMPILE_Button_Interrupt // reads a button using interrupts +//#define COMPILE_BlinkWithoutDelay +#define COMPILE_Debounce // reads button using interrupt and timer + callback to debounce the input +//#define COMPILE_DigitalInputPullup +//#define COMPILE_StateChangeDetection +//#define COMPILE_ToneKeyboard +//#define COMPILE_ToneMelody +//#define COMPILE_ToneMultiple +//#define COMPILE_TonePitchFollower + + +// 03_Analog: +//#define COMPILE_ADC_Internal // reads the uController internal temperature, VREF and VBAT inputs. +//#define COMPILE_AnalogInOutSerial +//#define COMPILE_AnalogInput +//#define COMPILE_AnalogWrite +//#define COMPILE_Calibration +//#define COMPILE_Fading +//#define COMPILE_Smoothing + + +// 04_Control: +//#define COMPILE_arrays +//#define COMPILE_for loop itteration +//#define COMPILE_if statement conditional +//#define COMPILE_switch case +//#define COMPILE_switch case 2 +//#define COMPILE_while statement conditional +//#defien COMPILE_compiler_directives + + +// 05_strings: +//#define COMPILE_character analysis +//#define COMPILE_string addition operator +//#define COMPILE_string append +//#define COMPILE_string case change +//#define COMPILE_string characters +//#define COMPILE_strinc comparison +//#define COMPILE_string constructor +//#define COMPILE_string index of +//#define COMPILE_string length +//#define COMPILE_length trim +//#define COMPILE_string replace +//#define COMPILE_string starts ends with +//#define COMPILE_substring +//#define COMPILE_string to int -/* 01_Basics: -AnalogReadSerial -Blink -DigitalReadSerial -Fade -ReadAnalogVoltage -*/ -//#define COMPILE_Analog_In -#define COMPILE_Button_Interrupt - -/* +// 06_Communication: +//#define COMPILE_AScii table +//#define COMPILE_Dimmer +//#define COMPILE_Graph +//#define COMPILE_Midi +//#define COMPILE_Multiserial +//#define COMPILE_physicalPixel +//#define COMPILE_ReadAScii string +//#define COMPILE_serial call response +//#define COMPILE_serial call response ascii +//#define COMPILE_serial event +//#define COMPILE_serial pass through +//#define COMPILE_virtual color mixer -02_Digital -BlinkWithoutDelay -Button -Debounce -DigitalInputPullup -StateChangeDetection -ToneKeyboard -ToneMelody -ToneMultiple -TonePitchFollower -03_Analog -AnalogInOutSerial -AnalogInput -AnalogWrite -Calibration -Fading -Smoothing +// 07_Special_Hardware: +//#define COMPILE_I2C +//#define COMPILE_SPI +//#define COMPILE_PWM +//#define COMPILE_CaptureCompare +//#define COMPILE_ + + +// 08_USB: +//#define COMPILE_Keyboard +//#define COMPILE_key and mouse +//#define COMPILE_mouse + -04_Communication -AScii table -Dimmer -Graph -Midi -Multiserial -physicalPixel -ReadAScii string -serial call response -serial call response ascii -serial event -serial pass through -virtual color mixer +// 09_Files_SD: +//#define COMPILE_SD_Hello +//#define COMPILE_SD_SpeedTest +//#define COMPILE_FatFileSystem +//#define COMPILE_Index_and_CSV -05_Control -arrays -for loop itteration -if statement conditional -switch case -switch case 2 -while statement conditional -06_sensors -ADXL3xx -Knock -Memsic2125 -Ping -GPS +// 10_Sensors: +//#define COMPILE_ADXL3xx +//#define COMPILE_Knock +//#define COMPILE_Memsic2125 +//#define COMPILE_Ping +//#define COMPILE_GPS +//#define COMPILE_BNO055 +//#define COMPILE_BMP280 +//#define COMPILE_BQ27441 +//#define COMPILE_LM335 +//#define COMPILE_MCP9700 -07_Display -bar graph -row column scanning -08_strings -character analysis -string addition operator -string append -string case change -string characters -strinc comparison -string constructor -string index of -string length -length trim -string replace -string starts ends with -substring -string to int +// 11_RTOS: + + +// 12_Ethernet: -09_USB -Keyboard -key and mouse -mouse -*/ \ No newline at end of file +// 13_Projects: + + +// reorganizing +// display +//#define COMPILE_bar graph +//#define COMPILE_row column scanning \ No newline at end of file