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: SoftSerial SDFileSystem mbed wave_player
Diff: main.cpp
- Revision:
- 3:f128424d2e80
- Parent:
- 1:6b839581dc9f
- Child:
- 4:a07612fbf279
--- a/main.cpp Wed Apr 26 07:39:53 2017 +0000 +++ b/main.cpp Tue May 02 19:20:21 2017 +0200 @@ -1,80 +1,8 @@ -#define TX_MODE 0 //E -//#define TX_MODE 1 //F #include "mbed.h" -#include "C12832.h" -#include "Buffer.h" -#include "SoftSerial.h" -#include "BufferedSoftSerial.h" - -C12832 lcd(p5, p7, p6, p8, p11); -//BufferedSoftSerial buf(p9, p10); -Serial uart(p9, p10); - -void to_manchester(char* in, int size, char* out){ - int m_char_index = 0; - for(int char_index = 0; char_index < size; char_index++){ - bool bits[16]; // manchester char - int m_bit_index = 0; - //split in bits and insert inverse - for(int j = 0; j < 8; j++){ // iterate over all the bits in the char - bool bit = (bool) ((in[char_index] >> 7-j) & 1); - bits[m_bit_index] = bit; - m_bit_index++; - bits[m_bit_index] = !bit; - m_bit_index++; - } - //combine back to 2 chars //todo dry - int bit_index = 0; - for(int j = 0; j < 8; j++){ //assemble first char - out[m_char_index] = out[m_char_index] | (bits[bit_index] << (7-j)); - bit_index++; - } - m_char_index++; - for(int j = 0; j < 8; j++){ // assemble second char - out[m_char_index] = out[m_char_index] | (bits[bit_index] << (7-j)); - bit_index++; - } - m_char_index++; - } -} - -void print_bits(char* buffer, int size){ - for(int i = 0; i < size; i++){ - for(int j = 0; j < 8; j++){ - int bit = ((buffer[i] >> 7-j) & 1); - lcd.printf("%i",bit); - } - lcd.printf(" "); - } -} int main() { - lcd.cls(); - lcd.locate(0,0); - char s[2]; - s[0] = '\0'; - s[1] = 15; - print_bits(s,2); - lcd.printf("\r\n"); - char m[4]; - to_manchester(s,2,m); - print_bits(m,4); - /** - uart.baud(9600); - lcd.cls(); - lcd.printf("mbed application board!"); - while(true){ - if (TX_MODE){ - uart.printf("Hello World - buffered \r\n"); - wait(0.1f); - } else { - char r[64]; - //buf.gets(r, 64); - //lcd.printf("%s",r); - lcd.putc(uart.getc()); - } - }**/ + printf("%s", "hello, term"); }