servodisc goodness
Embed:
(wiki syntax)
Show/hide line numbers
cube.h
00001 #ifndef _cube_h 00002 #define _cube_h 00003 00004 #include <stdint.h> 00005 // special serial commands 00006 #define K_START (0x1<<6) 00007 #define K_MOVES (0x3<<6) 00008 #define K_END (0x2<<6) 00009 00010 #define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c" 00011 #define BYTE_TO_BINARY(byte) \ 00012 (byte & 0x80 ? '1' : '0'), \ 00013 (byte & 0x40 ? '1' : '0'), \ 00014 (byte & 0x20 ? '1' : '0'), \ 00015 (byte & 0x10 ? '1' : '0'), \ 00016 (byte & 0x08 ? '1' : '0'), \ 00017 (byte & 0x04 ? '1' : '0'), \ 00018 (byte & 0x02 ? '1' : '0'), \ 00019 (byte & 0x01 ? '1' : '0') 00020 // cube faces 00021 enum face_t 00022 { 00023 Us = 0, 00024 D = 1, 00025 L = 2, 00026 R = 3, 00027 F = 4, 00028 B = 5 00029 }; 00030 00031 // a single move, consisting of a face 00032 // and number of CW rotations 00033 struct move_t 00034 { 00035 face_t face; 00036 int8_t n_turns; 00037 }; 00038 00039 // a sequence of moves: 00040 // pointer to start of an array of moves 00041 // length of the array 00042 struct sequence_t 00043 { 00044 move_t* moves; 00045 uint8_t n_moves; 00046 }; 00047 00048 // all the information that the simulated board needs to run the sequence 00049 // for the actual implementation, keep only seq and face 00050 // calls to small_delay, rotate, {get,set}_and should be 00051 // replaced with calls to Ben's functions 00052 struct mbed_info_t 00053 { 00054 face_t face; // the face that this board corresponds to 00055 sequence_t* seq; // the sequence to follow 00056 void(*rotate)(int8_t, int8_t); // rotate a face n turns, second argument is board number (needed for simulation) 00057 void(*set_and)(int8_t, int8_t); // sets and output, second argument is board number (needed for simulation) 00058 int8_t(*get_and)(); // gets and board status 00059 }; 00060 00061 int sequence_to_serial(sequence_t* seq, uint8_t* buffer, int n_bytes); 00062 int serial_to_sequence(sequence_t* seq, uint8_t* buffer, int n_bytes); 00063 void string_to_sequence(char* string); 00064 00065 //void* run_sequence(void* command); 00066 void* run_sequence_2(void* command); 00067 void print_sequence(sequence_t* seq); 00068 void reset_mbed(); 00069 sequence_t* get_sequence(); 00070 #endif
Generated on Tue Jul 19 2022 04:12:03 by 1.7.2