Adafruit FeatherOLED example for the MAX32630FTHR board
Dependencies: Adafruit_FeatherOLED USBDevice max32630fthr
Dependents: Bracciale_master Bracciale_slave
Fork of FTHR_USB_serial by
main.cpp
00001 /********************************************************************** 00002 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a 00005 * copy of this software and associated documentation files (the "Software"), 00006 * to deal in the Software without restriction, including without limitation 00007 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00008 * and/or sell copies of the Software, and to permit persons to whom the 00009 * Software is furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included 00012 * in all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00015 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00016 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00017 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00018 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00019 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00020 * OTHER DEALINGS IN THE SOFTWARE. 00021 * 00022 * Except as contained in this notice, the name of Maxim Integrated 00023 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00024 * Products, Inc. Branding Policy. 00025 * 00026 * The mere transfer of this software does not imply any licenses 00027 * of trade secrets, proprietary technology, copyrights, patents, 00028 * trademarks, maskwork rights, or any other form of intellectual 00029 * property whatsoever. Maxim Integrated Products, Inc. retains all 00030 * ownership rights. 00031 **********************************************************************/ 00032 00033 #include "mbed.h" 00034 #include "max32630fthr.h" 00035 #include "Adafruit_SSD1306.h" 00036 #include "USBSerial.h" 00037 00038 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); 00039 00040 I2C i2c(P3_4, P3_5); // SDA, SCL 00041 00042 // Hardware serial port over DAPLink 00043 Serial daplink(P2_1, P2_0); 00044 00045 // Virtual serial port over USB 00046 USBSerial microUSB; 00047 00048 DigitalOut rLED(LED1); 00049 DigitalOut gLED(LED2); 00050 DigitalOut bLED(LED3); 00051 00052 DigitalIn aButton(P5_3, PullUp); 00053 DigitalIn bButton(P3_3, PullUp); 00054 DigitalIn cButton(P3_2, PullUp); 00055 00056 /* Analog inputs 0 and 1 have internal dividers to allow measuring 5V signals 00057 * The dividers are selected by using inputs AIN_5 and AIN_5 respectively. 00058 * The full scale range for AIN0-3 is 1.2V 00059 * The full scale range for AIN4-5 is 6.0V 00060 */ 00061 AnalogIn ain0(AIN_4); 00062 AnalogIn ain1(AIN_5); 00063 AnalogIn ain2(AIN_2); 00064 AnalogIn ain3(AIN_3); 00065 00066 00067 // main() runs in its own thread in the OS 00068 // (note the calls to Thread::wait below for delays) 00069 int main() 00070 { 00071 int c; 00072 c = ' '; 00073 00074 daplink.printf("daplink serial port\r\n"); 00075 microUSB.printf("micro USB serial port\r\n"); 00076 rLED = LED_ON; 00077 gLED = LED_ON; 00078 bLED = LED_OFF; 00079 00080 00081 Thread::wait(50); // Give the supplies time to settle before initializing the display 00082 Adafruit_SSD1306_I2c featherOLED(i2c); 00083 featherOLED.printf("%ux%u OLED Display\r\n", featherOLED.width(), featherOLED.height()); 00084 featherOLED.printf("HelloWorld \r"); 00085 featherOLED.display(); 00086 00087 00088 while(1) { 00089 Thread::wait(250); 00090 if (microUSB.readable()) { 00091 c = microUSB.getc(); 00092 microUSB.putc(c); 00093 daplink.putc(c); 00094 } 00095 if (daplink.readable()) { 00096 c = daplink.getc(); 00097 microUSB.putc(c); 00098 daplink.putc(c); 00099 } 00100 rLED = aButton; 00101 gLED = bButton; 00102 bLED = cButton; 00103 featherOLED.clearDisplay(); 00104 featherOLED.setTextCursor(0,0); 00105 featherOLED.printf("MAX32630FTHR OLED\n"); 00106 featherOLED.printf("AIN0/1: %1.2f, %1.2f\n", (6.0f * ain0), (6.0f * ain1) ); // analog inputs 0,1 00107 featherOLED.printf("AIN2/3: %1.2f, %1.2f\n", (1.2f * ain2), (1.2f * ain3) ); // analog inputs 2,3 00108 featherOLED.printf("UART:%c A:%d B:%d C:%d\n", c, aButton.read(), bButton.read(), cButton.read()); // UART and Buttons 00109 featherOLED.display(); 00110 00111 } 00112 } 00113
Generated on Fri Jul 15 2022 07:45:01 by 1.7.2