// /** // * This is the main Blank Simple C++ Project program file. // */ // #include "servodiffdrive.h"s // #include // Recommended over iostream for saving space // #include // Propeller-specific functions // const int MOTOR_LEFT_PIN = 13; // const int MOTOR_RIGHT_PIN = 12; // int main(){ // // Add your code here // // drive_pins(MOTOR_LEFT_PIN, MOTOR_RIGHT_PIN); // // drive_speeds(100,100); // drive_setRampStep(10); // 10 ticks/sec / 20 ms // drive_ramp(128, 128); // Forward 2 RPS // return 0; // } #include "simpletools.h" #include "fdserial.h" #define SERIAL_TX_PIN 30 #define SERIAL_RX_PIN 31 #define LED_DATA_PIN 7 #define LED_CLK_PIN 8 fdserial *serialCom; void load_led_pattern(uint8_t, int , int); int main() { uint8_t pattern = 0x00000001; serialCom = fdserial_open(31, 30, 0, 9600); // Rx, Tx, Mode, Baudrate writeChar(serialCom, CLS); dprint(serialCom, "Starting load of pattern\n"); load_led_pattern(pattern, LED_DATA_PIN, LED_CLK_PIN); dprint(serialCom, "LED Pattern loaded: %x\n", pattern); dprint(serialCom, "Click this terminal, \n"); dprint(serialCom, "and type on keyboard...\n\n"); char c; // high(7); while(1) { c = fdserial_rxChar(serialCom); if(c != -1) { dprint(serialCom, "You typed: %c\n", c); } } } void load_led_pattern(uint8_t pattern, int data_pin, int clock_pin){ /*Byte pattern: Q7...Q0 */ int i; low(clock_pin); for(i = 0; i < 8; i++){ low(clock_pin); uint8_t output_value = (pattern & (0x1 << (7 - i))); dprint(serialCom, "Shifting in %x\n", output_value); if(output_value){ high(data_pin); }else{ low(data_pin); } high(clock_pin); } }