hexiwear RTC display Serial
Dependencies: Hexi_KW40Z Hexi_OLED_SSD1351 mbed
Revision 0:64ad287703be, committed 2017-09-05
- Comitter:
- i_am_kitsune
- Date:
- Tue Sep 05 01:49:30 2017 +0000
- Commit message:
- Hexiwear display RTC
Changed in this revision
diff -r 000000000000 -r 64ad287703be .gitignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Tue Sep 05 01:49:30 2017 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
diff -r 000000000000 -r 64ad287703be Hexi_KW40Z.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Hexi_KW40Z.lib Tue Sep 05 01:49:30 2017 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/Hexiwear/code/Hexi_KW40Z/#3f5ed7abc5c7
diff -r 000000000000 -r 64ad287703be Hexi_OLED_SSD1351.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Hexi_OLED_SSD1351.lib Tue Sep 05 01:49:30 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/teams/Hexiwear/code/Hexi_OLED_SSD1351/#ae5fad429790
diff -r 000000000000 -r 64ad287703be MTCH6102.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MTCH6102.h Tue Sep 05 01:49:30 2017 +0000 @@ -0,0 +1,48 @@ +#define MTCH6102_I2CADDR_DEFAULT 0x25 + + +#define MTCH6102_MODE 0x05 +#define MTCH6102_MODE_STANDBY 0000 +#define MTCH6102_MODE_GESTURE 0001 +#define MTCH6102_MODE_TOUCH 0010 +#define MTCH6102_MODE_FULL 0011 +#define MTCH6102_MODE_RAW 0100 + +#define MTCH6102_NUMBEROFXCHANNELS 0x20 +#define MTCH6102_NUMBEROFYCHANNELS 0x21 +#define MTCH6102_TOUCHSTATE 0x10 +#define MTCH6102_TOUCHX 0x11 +#define MTCH6102_TOUCHY 0x12 +#define MTCH6102_TOUCHLSB 0x13 + +#define MTCH6102_SENSORVALUE_RX0 0x80 +#define MTCH6102_SENSORVALUE_RX1 0x81 +#define MTCH6102_SENSORVALUE_RX2 0x82 +#define MTCH6102_SENSORVALUE_RX3 0x83 +#define MTCH6102_SENSORVALUE_RX4 0x84 +#define MTCH6102_SENSORVALUE_RX5 0x85 +#define MTCH6102_SENSORVALUE_RX6 0x86 +#define MTCH6102_SENSORVALUE_RX7 0x87 +#define MTCH6102_SENSORVALUE_RX8 0x88 +#define MTCH6102_SENSORVALUE_RX9 0x89 +#define MTCH6102_SENSORVALUE_RX10 0x8A +#define MTCH6102_SENSORVALUE_RX11 0x8B +#define MTCH6102_SENSORVALUE_RX12 0x8C +#define MTCH6102_SENSORVALUE_RX13 0x8D +#define MTCH6102_SENSORVALUE_RX14 0x8E + +class MTCH6102 { + public: + +// MTCH6102(void); +// +// boolean begin(uint8_t i2caddr = MTCH6102_I2CADDR_DEFAULT); +// +// uint8_t readRegister(uint8_t reg); +// void writeRegister(uint8_t reg, uint8_t value); +// +// void setMode(uint8_t mode); + + private: + int8_t _i2caddr; +}; \ No newline at end of file
diff -r 000000000000 -r 64ad287703be README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Tue Sep 05 01:49:30 2017 +0000 @@ -0,0 +1,87 @@ +# Getting started with Blinky on mbed OS + +This guide reviews the steps required to get Blinky working on an mbed OS platform. + +Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). + +## Import the example application + +From the command-line, import the example: + +``` +mbed import mbed-os-example-blinky +cd mbed-os-example-blinky +``` + +### Now compile + +Invoke `mbed compile`, and specify the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5: + +``` +mbed compile -m K64F -t ARM +``` + +Your PC may take a few minutes to compile your code. At the end, you see the following result: + +``` +[snip] ++----------------------------+-------+-------+------+ +| Module | .text | .data | .bss | ++----------------------------+-------+-------+------+ +| Misc | 13939 | 24 | 1372 | +| core/hal | 16993 | 96 | 296 | +| core/rtos | 7384 | 92 | 4204 | +| features/FEATURE_IPV4 | 80 | 0 | 176 | +| frameworks/greentea-client | 1830 | 60 | 44 | +| frameworks/utest | 2392 | 512 | 292 | +| Subtotals | 42618 | 784 | 6384 | ++----------------------------+-------+-------+------+ +Allocated Heap: unknown +Allocated Stack: unknown +Total Static RAM memory (data + bss): 7168 bytes +Total RAM memory (data + bss + heap + stack): 7168 bytes +Total Flash memory (text + data + misc): 43402 bytes +Image: .\.build\K64F\ARM\mbed-os-example-blinky.bin +``` + +### Program your board + +1. Connect your mbed device to the computer over USB. +1. Copy the binary file to the mbed device. +1. Press the reset button to start the program. + +The LED on your platform turns on and off. + +## Export the project to Keil MDK, and debug your application + +From the command-line, run the following command: + +``` +mbed export -m K64F -i uvision +``` + +To debug the application: + +1. Start uVision. +1. Import the uVision project generated earlier. +1. Compile your application, and generate an `.axf` file. +1. Make sure uVision is configured to debug over CMSIS-DAP (From the Project menu > Options for Target '...' > Debug tab > Use CMSIS-DAP Debugger). +1. Set breakpoints, and start a debug session. + +![Image of uVision](img/uvision.png) + +## Troubleshooting + +1. Make sure `mbed-cli` is working correctly and its version is `>1.0.0` + + ``` + mbed --version + ``` + + If not, you can update it: + + ``` + pip install mbed-cli --upgrade + ``` + +2. If using Keil MDK, make sure you have a license installed. [MDK-Lite](http://www.keil.com/arm/mdk.asp) has a 32 KB restriction on code size. \ No newline at end of file
diff -r 000000000000 -r 64ad287703be img/uvision.png Binary file img/uvision.png has changed
diff -r 000000000000 -r 64ad287703be main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Sep 05 01:49:30 2017 +0000 @@ -0,0 +1,97 @@ +/* + CREATED BY JAICHANGPARK AKA DREAMWALKER + DATE : 2017. 06. 28 + +*/ + +#include "mbed.h" +#include "Hexi_OLED_SSD1351.h" +#include "Hexi_KW40Z.h" +#include "string.h" +#include "MTCH6102.h" + + +DigitalOut led1(LED1); + +/** +* HEXIWEAR SERIAL PORT + TX : PTD3, USBTX(WITH PC) + RX : PTD2, USBRX(WITH PC) +**/ + +Serial serial(USBTX,USBRX,9600); //(TX, RX) + +/* + HEXIWEAR OLED INTERNAL DISPLAY PIN + MOSI(SDI) : PTB22 + SCLK(SCK) : PTB21 + POWER : PTC13 ( INTERNAL POWER PORT) + CS : PTB20 + RST : PTE6 + DC : PTD15 +*/ +SSD1351 display(PTB22,PTB21,PTC13,PTB20,PTE6, PTD15); + +/* + KW40Z INIT + UART4 + TX : PTE24 + RX : PTE25 +*/ + +KW40Z kw40z_device(PTE24, PTE25); + +// main() runs in its own thread in the OS +int main() { + + char time_text[20]; + char date_text[25]; + + // Use default properties + oled_text_properties_t textProperties = {0}; + display.GetTextProperties(&textProperties); + display.FillScreen(COLOR_BLACK); + + textProperties.fontColor = COLOR_WHITE; + textProperties.alignParam = OLED_TEXT_ALIGN_CENTER; + display.SetTextProperties(&textProperties); + + while (true) { + + time_t seconds = time(NULL); + const tm *t = localtime(&seconds); // Convert the unix time to actual time + char* s = "AM"; // The suffix to use for the time of day + int h = (t->tm_hour) + 18; // The hours + int year = (t->tm_year) + 1947; + if (h > 12){ // If it's entering 24/h time, change it to 12/h and add PM + s = "PM"; + h = h - 12; + } + + // Format the time + sprintf(time_text,"%d:%d:%d %s",h, t->tm_min, t->tm_sec, s); + sprintf(date_text,"%d-%d-%d",year, (t->tm_mon)+6, (t->tm_mday)+27); + + serial.printf(time_text); + serial.printf("\n"); + serial.printf(date_text); + serial.printf("\n"); + + // Display the time on screen + // oled_status_t SSD1351::TextBox(const uint8_t* text, int8_t xCrd, int8_t yCrd,uint8_t width,uint8_t height) + display.TextBox((uint8_t *)time_text,2,2, 91, 15); + display.TextBox((uint8_t *)date_text,2,16, 91, 15); + led1 = !led1; + wait(0.5); + } +} + +void edited_time(){ + + char buffer[32]; + time_t init_time = time(NULL); + strftime(buffer, 32, "%I:%M %p\n", localtime(&init_time)); + printf("Time as a custom formatted string = %s", buffer); + +} +
diff -r 000000000000 -r 64ad287703be mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Tue Sep 05 01:49:30 2017 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#c9e63f14085f5751ff5ead79a7c0382d50a813a2
diff -r 000000000000 -r 64ad287703be mbed.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.lib Tue Sep 05 01:49:30 2017 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/screamer/code/mbed/#aff670d0d510