//************************************************************************************ //** //** File name: C:\001TECH\Products\PropClock\Firmware\v20.c //** Generated by: Flowcode v4.4.13.69 //** Date: Saturday, November 24, 2012 14:43:28 //** Licence: Professional //** Registered to: Ben Rowland //** //** //** http://www.matrixmultimedia.com //************************************************************************************ #define MX_PIC_16BIT //Defines for microcontroller #define dsPIC33 #define P33FJ128MC204 #define MX_CLKS_PER_INST 2 #define MX_SPI1 #define MX_SPI1_PORT_FREEALLOC #define MX_SPI2 #define MX_SPI2_PORT_FREEALLOC #define MX_UART1 #define MX_UART1_PORT_FREEALLOC #define MX_UART2 #define MX_UART2_PORT_FREEALLOC #define MX_MI2C1 #define MX_I2C1_PORT_B #define MX_I2C1_SDA 9 #define MX_I2C1_SCL 8 #define MX_PWM #define MX_PWM_PORT_FREEALLOC #define MX_PWM_CNT 4 #define MX_PWM_1 0 #define MX_PWM_2 1 //Functions #define MX_Fosc 80000000 #include "../support/dsPIC33F/h/p33Fxxxx.h" #include #include //Configuration data _FBS(0xcf) //addr = 0xf80000 _FSS(0xcf) //addr = 0xf80002 _FGS(0x7) //addr = 0xf80004 _FOSCSEL(0x3) //addr = 0xf80006 _FOSC(0x46) //addr = 0xf80008 _FWDT(0x5f) //addr = 0xf8000a _FPOR(0xf7) //addr = 0xf8000c _FICD(0xc3) //addr = 0xf8000e //Internal functions #include "C:\Program Files (x86)\Matrix Multimedia\Flowcode PIC24&dsPIC V4\FCD\internals.h" //Macro function declarations //Variable declarations #define FCSZ_TST 3 volatile char FCV_TST[FCSZ_TST]; volatile short FCV_SEG; volatile char FCV_REV2; volatile char FCV_X; volatile char FCV_Y; volatile char FCV_HOUR; volatile char FCV_TEMP; volatile char FCV_DAY; volatile char FCV_COUNT; volatile char FCV_SOUND; volatile char FCV_COLOUR; volatile char FCV_SEC; volatile char FCV_MONTH; volatile char FCV_SHAPE; volatile char FCV_MIN; volatile char FCV_TICK; volatile char FCV_YEAR; volatile char FCV_REV; char FCLV_LOOP1; //Defines: //common defines #define OFFSET 0 #define NUM_LEDS 24 #define NUM_SEGMENTS 240 #define SEGMENT_MASK 0x01 //0=No Segment Blanking, 1=1:1, 3=1:3 #define SEG_CNT (NUM_SEGMENTS * (SEGMENT_MASK + 1)) #define DEG_CNT_180 (NUM_SEGMENTS / 2) #define PI 3.141592 #define RADS_TO_SEGS (DEG_CNT_180 / PI) #define SCALE_3D 50 #define NUM_SIGNALS (NUM_LEDS * 3) #define NUM_BUFFERS (NUM_SIGNALS / 8) #define NUM_BYTES (NUM_SEGMENTS * NUM_BUFFERS) //Thermistor Defines #define MX_ADC_CHANNEL 0 #define MX_ADC_SAMP_TIME 40 #define MX_ADC_CONV_SP 15 #define MX_ADC_VREF_OPT 0 //global variables volatile char SEC = 0; volatile char MIN = 0; volatile char HOUR = 17; volatile char DAY = 6; volatile char WDAY = 0; volatile char MONTH = 3; volatile char YEAR = 11; volatile char REVS = 0; volatile char REVCNT = 0; volatile unsigned short SEG_COUNTER = 0; volatile unsigned short OFFSEG = OFFSET; volatile unsigned short TMR_COUNT = 0xF800; volatile unsigned short SEG_IDX; volatile char COMMAND = 0; volatile char ADDRESS = 0; //Video Memory volatile char VRAM[NUM_BYTES]; //3D Definitions #define SPEED_1X 0.017 #define SPEED_2X 0.034 #define SPEED_4X 0.068 #define DPHI SPEED_4X #define R 1 //Vertex Buffer float x[12], y[12], z[12]; float xview[12], yview[12], zview[12]; short xs[12], ys[12], zs[12]; short xsp[12], ysp[12], zsp[12]; char visible[20]; char visiblep[20]; char Shape = 0; char Vertex_Count = 0; //Viewpoint Settings float eview = 0; char d = 4; //ASCII Pixel data const char ASCII[] = { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , // 32 = 0x00 , 0x06 , 0x5F , 0x06 , 0x00 , // 33 = ! 0x07 , 0x03 , 0x00 , 0x07 , 0x03 , // 34 = " 0x24 , 0x7E , 0x24 , 0x7E , 0x24 , // 35 = # 0x24 , 0x2B , 0x6A , 0x12 , 0x00 , // 36 = $ 0x63 , 0x13 , 0x08 , 0x64 , 0x63 , // 37 = % 0x36 , 0x49 , 0x56 , 0x20 , 0x50 , // 38 = & 0x00 , 0x07 , 0x03 , 0x00 , 0x00 , // 39 = ' 0x00 , 0x3E , 0x41 , 0x00 , 0x00 , // 40 = ( 0x00 , 0x41 , 0x3E , 0x00 , 0x00 , // 41 = ) 0x08 , 0x3E , 0x1C , 0x3E , 0x08 , // 42 = * 0x08 , 0x08 , 0x3E , 0x08 , 0x08 , // 43 = + 0x00 , 0xE0 , 0x60 , 0x00 , 0x00 , // 44 = , 0x08 , 0x08 , 0x08 , 0x08 , 0x08 , // 45 = - 0x00 , 0x60 , 0x60 , 0x00 , 0x00 , // 46 = . 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , // 47 = / 0x3E , 0x51 , 0x49 , 0x45 , 0x3E , // 48 = 0 0x00 , 0x42 , 0x7F , 0x40 , 0x00 , // 49 = 1 0x62 , 0x51 , 0x49 , 0x49 , 0x46 , // 50 = 2 0x22 , 0x49 , 0x49 , 0x49 , 0x36 , // 51 = 3 0x18 , 0x14 , 0x12 , 0x7F , 0x10 , // 52 = 4 0x2F , 0x49 , 0x49 , 0x49 , 0x31 , // 53 = 5 0x3C , 0x4A , 0x49 , 0x49 , 0x30 , // 54 = 6 0x01 , 0x71 , 0x09 , 0x05 , 0x03 , // 55 = 7 0x36 , 0x49 , 0x49 , 0x49 , 0x36 , // 56 = 8 0x06 , 0x49 , 0x49 , 0x29 , 0x1E , // 57 = 9 0x00 , 0x6C , 0x6C , 0x00 , 0x00 , // 58 = : 0x00 , 0xEC , 0x6C , 0x00 , 0x00 , // 59 = ; 0x08 , 0x14 , 0x22 , 0x41 , 0x00 , // 60 = < 0x24 , 0x24 , 0x24 , 0x24 , 0x24 , // 61 = = 0x00 , 0x41 , 0x22 , 0x14 , 0x08 , // 62 = > 0x02 , 0x01 , 0x59 , 0x09 , 0x06 , // 63 = ? 0x3E , 0x41 , 0x5D , 0x55 , 0x1E , // 64 = @ 0x7E , 0x09 , 0x09 , 0x09 , 0x7E , // 65 = A 0x7F , 0x49 , 0x49 , 0x49 , 0x36 , // 66 = B 0x3E , 0x41 , 0x41 , 0x41 , 0x22 , // 67 = C 0x7F , 0x41 , 0x41 , 0x41 , 0x3E , // 68 = D 0x7F , 0x49 , 0x49 , 0x49 , 0x41 , // 69 = E 0x7F , 0x09 , 0x09 , 0x09 , 0x01 , // 70 = F 0x3E , 0x41 , 0x49 , 0x49 , 0x7A , // 71 = G 0x7F , 0x08 , 0x08 , 0x08 , 0x7F , // 72 = H 0x00 , 0x41 , 0x7F , 0x41 , 0x00 , // 73 = I 0x30 , 0x40 , 0x40 , 0x40 , 0x3F , // 74 = J 0x7F , 0x08 , 0x14 , 0x22 , 0x41 , // 75 = K 0x7F , 0x40 , 0x40 , 0x40 , 0x40 , // 76 = L 0x7F , 0x02 , 0x04 , 0x02 , 0x7F , // 77 = M 0x7F , 0x02 , 0x04 , 0x08 , 0x7F , // 78 = N 0x3E , 0x41 , 0x41 , 0x41 , 0x3E , // 79 = O 0x7F , 0x09 , 0x09 , 0x09 , 0x06 , // 80 = P 0x3E , 0x41 , 0x51 , 0x21 , 0x5E , // 81 = Q 0x7F , 0x09 , 0x09 , 0x19 , 0x66 , // 82 = R 0x26 , 0x49 , 0x49 , 0x49 , 0x32 , // 83 = S 0x01 , 0x01 , 0x7F , 0x01 , 0x01 , // 84 = T 0x3F , 0x40 , 0x40 , 0x40 , 0x3F , // 85 = U 0x1F , 0x20 , 0x40 , 0x20 , 0x1F , // 86 = V 0x3F , 0x40 , 0x3C , 0x40 , 0x3F , // 87 = W 0x63 , 0x14 , 0x08 , 0x14 , 0x63 , // 88 = X 0x07 , 0x08 , 0x70 , 0x08 , 0x07 , // 89 = Y 0x71 , 0x49 , 0x45 , 0x43 , 0x00 , // 90 = Z 0x00 , 0x7F , 0x41 , 0x41 , 0x00 , // 91 = [ 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , // 92 = 0x00 , 0x41 , 0x41 , 0x7F , 0x00 , // 93 = ] 0x04 , 0x02 , 0x01 , 0x02 , 0x04 , // 94 = ^ 0x80 , 0x80 , 0x80 , 0x80 , 0x80 , // 95 = _ 0x00 , 0x03 , 0x07 , 0x00 , 0x00 , // 96 = ` 0x20 , 0x54 , 0x54 , 0x54 , 0x78 , // 97 = a 0x7F , 0x44 , 0x44 , 0x44 , 0x38 , // 98 = b 0x38 , 0x44 , 0x44 , 0x44 , 0x28 , // 99 = c 0x38 , 0x44 , 0x44 , 0x44 , 0x7F , // 100 = d 0x38 , 0x54 , 0x54 , 0x54 , 0x18 , // 101 = e 0x08 , 0x7E , 0x09 , 0x09 , 0x00 , // 102 = f 0x18 , 0xA4 , 0xA4 , 0xA4 , 0x7C , // 103 = g 0x7F , 0x04 , 0x04 , 0x78 , 0x00 , // 104 = h 0x00 , 0x00 , 0x7D , 0x00 , 0x00 , // 105 = i 0x40 , 0x80 , 0x84 , 0x7D , 0x00 , // 106 = j 0x7F , 0x10 , 0x28 , 0x44 , 0x00 , // 107 = k 0x00 , 0x00 , 0x7F , 0x40 , 0x00 , // 108 = l 0x7C , 0x04 , 0x18 , 0x04 , 0x78 , // 109 = m 0x7C , 0x04 , 0x04 , 0x78 , 0x00 , // 110 = n 0x38 , 0x44 , 0x44 , 0x44 , 0x38 , // 111 = o 0xFC , 0x44 , 0x44 , 0x44 , 0x38 , // 112 = p 0x38 , 0x44 , 0x44 , 0x44 , 0xFC , // 113 = q 0x44 , 0x78 , 0x44 , 0x04 , 0x08 , // 114 = r 0x08 , 0x54 , 0x54 , 0x54 , 0x20 , // 115 = s 0x04 , 0x3E , 0x44 , 0x24 , 0x00 , // 116 = t 0x3C , 0x40 , 0x20 , 0x7C , 0x00 , // 117 = u 0x1C , 0x20 , 0x40 , 0x20 , 0x1C , // 118 = v 0x3C , 0x60 , 0x30 , 0x60 , 0x3C , // 119 = w 0x6C , 0x10 , 0x10 , 0x6C , 0x00 , // 120 = x 0x9C , 0xA0 , 0x60 , 0x3C , 0x00 , // 121 = y 0x64 , 0x54 , 0x54 , 0x4C , 0x00 , // 122 = z 0x08 , 0x3E , 0x41 , 0x41 , 0x00 , // 123 = { 0x00 , 0x00 , 0x7F , 0x00 , 0x00 , // 124 = | 0x00 , 0x41 , 0x41 , 0x3E , 0x08 , // 125 = } 0x02 , 0x01 , 0x02 , 0x01 , 0x00 // 126 = ~ }; //Temperature LUT data const char TLUT[] = { 0, 0, 0, 0, 0, 0, 0, 1, 3, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 18, 19, 20, 21, 21, 22, 23, 23, 24, 25, 25, 26, 26, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40 }; //RTCC #define RTCCLock() RCFGCALbits.RTCWREN=0; #define RTCCOn() RCFGCALbits.RTCEN = 1; #define RTCCOff() RCFGCALbits.RTCEN = 0; #define EnableSecOsc() __builtin_write_OSCCONL(0x02); //UART Baud #define SPBRG_VAL ( 43 / MX_CLKS_PER_INST) //Custom2(0): //Macro function declarations static void FCD_Custom20_PWM_Control(); static void FCD_Custom20_SpinSync(); static void FCD_Custom20_Clear_Display(); static void FCD_Custom20_Rotate_Display(char direction); static void FCD_Custom20_Reset_Rotation(); static void FCD_Custom20_Modify_Pixel(short SEGMENT, char LED, char DATA); static void FCD_Custom20_Modify_Pixel_XY(short X, short Y, char DATA); static void FCD_Custom20_Draw_Axle(short SEGMENT, char STARTLED, char ENDLED, char COLOUR); static void FCD_Custom20_Draw_Arc(short STARTSEGMENT, short ENDSEGMENT, char LED, char COLOUR); static void FCD_Custom20_Draw_Circle(char LED, char COLOUR, char FILL); static void FCD_Custom20_Draw_Text_Polar(char* STRING, char MSZ_STRING, short SEGMENT, char LED, char ORIENTATION, char TRANSPARENT, char COLOUR); static void FCD_Custom20_Draw_Line(short X1, short Y1, short X2, short Y2, char COLOUR); static void FCD_Custom20_Setup_3D_Shape(char shape_template); static void FCD_Custom20_Calc_3D_Shape(); static void FCD_Custom20_Calc_Face_Tri(short n1, short n2, short n3, char idx); static void FCD_Custom20_Calc_Face_Sq(short n1, short n2, short n3, short n4, char idx); static void FCD_Custom20_Draw_3D_Shape(char Colour); static void FCD_Custom20_Draw_Face_Tri(short n1, short n2, short n3, char idx, char Colour); static void FCD_Custom20_Draw_Face_Sq(short n1, short n2, short n3, short n4, char idx, char Colour); static void FCD_Custom20_Rotate_3D_Shape(); static void FCD_Custom20_Draw_Text(char* String, char MSZ_String, short X, short Y, char Font, char Transparent, char FColour, char BColour); static char FCD_Custom20_Read_Temperature(); static char FCD_Custom20_Get_Rev_Count(); static void FCD_Custom20_Update_Time_Date(); static char FCD_Custom20_Read_Time_Date(char selection); static void FCD_Custom20_Timer_Tick(); //Custom2(0): //Macro implementations static void FCD_Custom20_PWM_Control() { //Local variable definitions char LOOP1; static char ODD = 0; TMR1 = TMR_COUNT; //LEDs OFF //Output: 1 -> B6 LATB = (LATB & 0xffbf) | 0x0040; #if (SEGMENT_MASK >= 1) if (ODD == 0) { #endif //Output to all LEDs to draw segment for (LOOP1=0; LOOP1 B5 LATB = (LATB & 0xffdf) | 0x0020; //Output: 0 -> B5 LATB = LATB & 0xffdf; //Load LED PWM into working register LATC = VRAM[SEG_IDX]; SEG_IDX++; if (SEG_IDX == NUM_BYTES) SEG_IDX = 0; } //LEDs ON //Output: 1 -> B6 LATB = LATB & 0xffbf; #if (SEGMENT_MASK >= 1) } ODD = (ODD + 1) & SEGMENT_MASK; #endif SEG_COUNTER++; } static void FCD_Custom20_SpinSync() { unsigned short difference = 0; if (SEG_COUNTER != SEG_CNT) { if (SEG_COUNTER < SEG_CNT) { if (TMR_COUNT < 0xFF00) { difference = SEG_CNT - SEG_COUNTER; if (difference > 5) TMR_COUNT = TMR_COUNT + 0x40; else if (difference > 3) TMR_COUNT = TMR_COUNT + 0x08; else if (difference > 1) TMR_COUNT = TMR_COUNT + 0x04; else TMR_COUNT = TMR_COUNT + 0x01; } } else { if (TMR_COUNT > 0x0040) { difference = SEG_COUNTER - SEG_CNT; if (difference > 5) TMR_COUNT = TMR_COUNT - 0x40; else if (difference > 3) TMR_COUNT = TMR_COUNT - 0x08; else if (difference > 1) TMR_COUNT = TMR_COUNT - 0x04; else TMR_COUNT = TMR_COUNT - 0x01; } } } //Move to first segment SEG_COUNTER = 0; SEG_IDX = (OFFSEG * NUM_BUFFERS); REVCNT++; //Trigger PWM Interrupt TMR1 = 0xFFFF; } static void FCD_Custom20_Clear_Display() { unsigned short CNT; CNT = 0; while (CNT < NUM_BYTES) { VRAM[CNT] = 0xFF; CNT = CNT + 1; } } static void FCD_Custom20_Rotate_Display(char direction) { if (direction) { if (OFFSEG) OFFSEG = OFFSEG - 1; else OFFSEG = NUM_SEGMENTS - 1; } else { OFFSEG++; if (OFFSEG == NUM_SEGMENTS) OFFSEG = 0; } } static void FCD_Custom20_Reset_Rotation() { OFFSEG = OFFSET; } static void FCD_Custom20_Modify_Pixel(short SEGMENT, char LED, char DATA) { //Local variable definitions char SHIFT = 0; char MASK; unsigned short ADDR = 0; //Init Variables if (LED >= NUM_LEDS) return; if (SEGMENT >= NUM_SEGMENTS) return; DATA = DATA << 5; //Can we save any time by skipping 8/16 leds? while (LED > 8) { LED = LED - 8; ADDR = ADDR + 3; } //Calculate shift position and LED address while (LED) { //Calculate Shift SHIFT = SHIFT + 3; if (SHIFT > 7) { ADDR = ADDR + 1; SHIFT = SHIFT & 0x07; } //Decrement LED count LED = LED - 1; } //Calculate RAM Address ADDR = (SEGMENT * 9) + ADDR; //Read VRAM LED = VRAM[ADDR]; //Update the byte MASK = 0xE0 >> SHIFT; LED = LED | MASK; MASK = (DATA & 0xE0) >> SHIFT; LED = LED & (~MASK); //Write VRAM VRAM[ADDR] = LED; if (SHIFT > 5) { //update address SHIFT = 8 - SHIFT; ADDR = ADDR + 1; //Read VRAM LED = VRAM[ADDR]; //Update the byte MASK = 0xE0 << SHIFT; LED = LED | MASK; MASK = (DATA & 0xE0) << SHIFT; LED = LED & (~MASK); //Write VRAM VRAM[ADDR] = LED; } } static void FCD_Custom20_Modify_Pixel_XY(short X, short Y, char DATA) { char quadrant; unsigned short Rad, Angle; float ang_temp; Rad = NUM_LEDS - sqrt((X * X) + (Y * Y)); if (Rad >= NUM_LEDS) //Off the display? return; if (X != 0) ang_temp = (float) Y / X; else ang_temp = (float) 2 * Y; ang_temp = atan(ang_temp); if ((X >= 0) && (Y >= 0)) //Calculate negative angle to get positive segment ang_temp = PI - ang_temp; else if ((X >= 0) && (Y < 0)) ang_temp = PI + (0 - ang_temp); else if ((X < 0) && (Y < 0)) ang_temp = (2 * PI) - ang_temp; else ang_temp = 0 - ang_temp; Angle = RADS_TO_SEGS * ang_temp; //Convert to segments if (Angle >= NUM_SEGMENTS) Angle = Angle - NUM_SEGMENTS; Angle = NUM_SEGMENTS - Angle; //Flip back to positive FCD_Custom20_Modify_Pixel(Angle, Rad, DATA); } static void FCD_Custom20_Draw_Axle(short SEGMENT, char STARTLED, char ENDLED, char COLOUR) { //Ensure Addressing Is Valid if (STARTLED >= NUM_LEDS) return; if (ENDLED >= NUM_LEDS) return; while (STARTLED != ENDLED) { FCD_Custom20_Modify_Pixel(SEGMENT, STARTLED, COLOUR); if (STARTLED <= ENDLED) { STARTLED = STARTLED + 1; } else { STARTLED = STARTLED - 1; } } FCD_Custom20_Modify_Pixel(SEGMENT, STARTLED, COLOUR); } static void FCD_Custom20_Draw_Arc(short STARTSEGMENT, short ENDSEGMENT, char LED, char COLOUR) { if (STARTSEGMENT >= NUM_SEGMENTS) return; if (ENDSEGMENT >= NUM_SEGMENTS) return; while (STARTSEGMENT != ENDSEGMENT) { FCD_Custom20_Modify_Pixel(STARTSEGMENT, LED, COLOUR); STARTSEGMENT++; if (STARTSEGMENT == NUM_SEGMENTS) STARTSEGMENT = 0; } FCD_Custom20_Modify_Pixel(STARTSEGMENT, LED, COLOUR); } static void FCD_Custom20_Draw_Circle(char LED, char COLOUR, char FILL) { FCD_Custom20_Modify_Pixel(0, LED, COLOUR); FCD_Custom20_Draw_Arc(1, NUM_SEGMENTS, LED, COLOUR); if (FILL) { while (LED < 24) { LED = LED + 1; FCD_Custom20_Modify_Pixel(0, LED, COLOUR); FCD_Custom20_Draw_Arc(1, NUM_SEGMENTS, LED, COLOUR); } } } static void FCD_Custom20_Draw_Text_Polar(char* STRING, char MSZ_STRING, short SEGMENT, char LED, char ORIENTATION, char TRANSPARENT, char COLOUR) { //Local variable definitions char LOOKUPCHAR; char ROWCOUNT; char LOOP1, LOOP3, LOOP4; unsigned short CHARACTER; //For Each Character In String for (LOOP1=0; LOOP1 126) return; CHARACTER = CHARACTER - 32; CHARACTER = CHARACTER * 5; //For 5 Bytes of Character for (LOOP3=0; LOOP3<5; LOOP3++) { //Collect 1/5th of ASCII Symbol LOOKUPCHAR = ASCII[CHARACTER]; //Reset Row Counter ROWCOUNT = LED; //5 x 7 Font Size for (LOOP4=0; LOOP4<8; LOOP4++) { //If Pixel Set if (LOOKUPCHAR & 0x01) { //Set Pixel FCD_Custom20_Modify_Pixel(SEGMENT, ROWCOUNT, COLOUR); } else if (TRANSPARENT == 0) //If Transparent { //Clear Pixel FCD_Custom20_Modify_Pixel(SEGMENT, ROWCOUNT, 0); } //If Orientation if (ORIENTATION) { //Count Down ROWCOUNT = ROWCOUNT - 1; } else { //Count Up ROWCOUNT = ROWCOUNT + 1; } LOOKUPCHAR = LOOKUPCHAR >> 1; } CHARACTER = CHARACTER + 1; if (ORIENTATION) { SEGMENT++; if (SEGMENT == NUM_SEGMENTS) SEGMENT = 0; } else { SEGMENT = (SEGMENT - 1); if (SEGMENT < 0) SEGMENT = NUM_SEGMENTS; } } if (ORIENTATION) { SEGMENT++; if (SEGMENT == NUM_SEGMENTS) SEGMENT = 0; } else { SEGMENT = (SEGMENT - 1); if (SEGMENT < 0) SEGMENT = NUM_SEGMENTS; } } } static void FCD_Custom20_Draw_Line(short X1, short Y1, short X2, short Y2, char COLOUR) { int C1, M1; signed int D1 = 0; signed int Pixelx; //number of X-pixels; signed int Pixely; //Number of Y-pixels signed char Xinc = 1; signed char Yinc = 1; X1 = X1 + 24; X2 = X2 + 24; Y1 = Y1 + 24; Y2 = Y2 + 24; Pixelx = X2 - X1; Pixely = Y2 - Y1; if (Pixelx < 0) //If negative X direction { Xinc = -1; Pixelx = 0 - Pixelx; } if (Pixely < 0) //If negative Y direction { Yinc = -1; Pixely = 0 - Pixely; } if (Pixely <= Pixelx) { C1 = 2 * Pixelx; M1 = 2 * Pixely; while (X1 != X2) { FCD_Custom20_Modify_Pixel_XY((X1 - 24), (Y1 - 24), COLOUR); //ForePlot line X1 = X1 + Xinc; D1 = D1 + M1; if (D1 > Pixelx) { Y1 = Y1 + Yinc; D1 = D1 - C1; } } } else { C1 = 2 * Pixely; M1 = 2 * Pixelx; while (Y1 != Y2) { FCD_Custom20_Modify_Pixel_XY((X1 - 24), (Y1 - 24), COLOUR); //ForePlot Line Y1 = Y1 + Yinc; D1 = D1 + M1; if (D1 > Pixely) { X1 = X1 + Xinc; D1 = D1 - C1; } } } FCD_Custom20_Modify_Pixel_XY((X1 - 24), (Y1 - 24), COLOUR); } static void FCD_Custom20_Setup_3D_Shape(char shape_template) { short vertex; float theta, phi; float cosvar, sinvar; Shape = shape_template; if (Shape == 0) //Square Face { Vertex_Count = 4; theta = 0.25 * PI; //Top 2 Vertices for (vertex = 0; vertex < 2; vertex++) { if (vertex == 0) phi = 0; if (vertex == 1) phi = PI; sinvar = sin(theta); cosvar = cos(phi); x[vertex] = sinvar * cosvar; x[vertex] = x[vertex] * R; cosvar = sin(phi); y[vertex] = sinvar * cosvar; y[vertex] = y[vertex] * R; cosvar = cos(theta); z[vertex] = R * cosvar; } x[2] = 0 - x[0]; //Bottom 2 Vertices z[2] = 0 - z[0]; y[2] = 0 - y[0]; x[3] = 0 - x[1]; z[3] = 0 - z[1]; y[3] = 0 - y[1]; } if (Shape == 1) //Offset Square Face { Vertex_Count = 4; theta = 0.25 * PI; //Top 2 Vertices for (vertex = 0; vertex < 2; vertex++) { if (vertex == 0) phi = 1.25 * PI; if (vertex == 1) phi = 1.75 * PI; sinvar = sin(theta); cosvar = cos(phi); x[vertex] = sinvar * cosvar; x[vertex] = x[vertex] * R; cosvar = sin(phi); y[vertex] = sinvar * cosvar; y[vertex] = y[vertex] * R; cosvar = cos(theta); z[vertex] = R * cosvar; } x[2] = 0 - x[0]; //Bottom 2 Vertices z[2] = 0 - z[0]; y[2] = y[0]; x[3] = 0 - x[1]; z[3] = 0 - z[1]; y[3] = y[1]; } if (Shape == 2) //Cuboid { Vertex_Count = 8; theta = 0.25 * PI; //Top 4 Vertices for (vertex = 0; vertex < 4; vertex++) { if (vertex == 0) phi = 0.25 * PI; if (vertex == 1) phi = 0.75 * PI; if (vertex == 2) phi = 1.25 * PI; if (vertex == 3) phi = 1.75 * PI; sinvar = sin(theta); cosvar = cos(phi); x[vertex] = sinvar * cosvar; x[vertex] = x[vertex] * R; cosvar = sin(phi); y[vertex] = sinvar * cosvar; y[vertex] = y[vertex] * R; cosvar = cos(theta); z[vertex] = R * cosvar; } x[4] = 0 - x[3]; //Bottom 4 Vertices z[4] = 0 - z[3]; y[4] = 0 - y[3]; x[5] = 0 - x[2]; z[5] = 0 - z[2]; y[5] = 0 - y[2]; x[6] = 0 - x[1]; z[6] = 0 - z[1]; y[6] = 0 - y[1]; x[7] = 0 - x[0]; z[7] = 0 - z[0]; y[7] = 0 - y[0]; } if (Shape == 3) //Isocahedron { Vertex_Count = 12; for (vertex = 0; vertex < 6; vertex++) { theta = 1.10715; //Top 6 Vertices if (vertex == 0) { theta = 0; phi = 0; } if (vertex == 1) phi = 0; if (vertex == 2) phi = 0.4 * PI; if (vertex == 3) phi = 0.8 * PI; if (vertex == 4) phi = 1.2 * PI; if (vertex == 5) phi = 1.6 * PI; sinvar = sin(theta); cosvar = cos(phi); x[vertex] = sinvar * cosvar; x[vertex] = x[vertex] * R; cosvar = sin(phi); y[vertex] = sinvar * cosvar; y[vertex] = y[vertex] * R; cosvar = cos(theta); z[vertex] = R * cosvar; } x[6] = 0 - x[4]; //Bottom 6 Vertices z[6] = 0 - z[4]; y[6] = 0 - y[4]; x[7] = 0 - x[5]; z[7] = 0 - z[5]; y[7] = 0 - y[5]; x[8] = 0 - x[1]; z[8] = 0 - z[1]; y[8] = 0 - y[1]; x[9] = 0 - x[2]; z[9] = 0 - z[2]; y[9] = 0 - y[2]; x[10] = 0 - x[3]; z[10] = 0 - z[3]; y[10] = 0 - y[3]; x[11] = 0 - x[0]; z[11] = 0 - z[0]; y[11] = 0 - y[0]; } } static void FCD_Custom20_Calc_3D_Shape() { if (Shape < 2) { FCD_Custom20_Calc_Face_Sq(0, 1, 2, 3, 0); } if (Shape == 2) { FCD_Custom20_Calc_Face_Sq(0, 1, 2, 3, 0); FCD_Custom20_Calc_Face_Sq(4, 6, 5, 7, 0); //Calc_Face_Sq(0, 1, 4, 5, 0); //Unnessisary faces //Calc_Face_Sq(0, 3, 4, 6, 0); //Calc_Face_Sq(5, 7, 1, 2, 0); //Calc_Face_Sq(6, 7, 2, 3, 0); } if (Shape == 3) { FCD_Custom20_Calc_Face_Tri(0, 1, 2, 0); FCD_Custom20_Calc_Face_Tri(0, 1, 5, 1); FCD_Custom20_Calc_Face_Tri(1, 10, 6, 2); FCD_Custom20_Calc_Face_Tri(5, 10, 9, 3); FCD_Custom20_Calc_Face_Tri(5, 1, 10, 4); FCD_Custom20_Calc_Face_Tri(1, 2, 6, 5); FCD_Custom20_Calc_Face_Tri(2, 7, 6, 6); FCD_Custom20_Calc_Face_Tri(9, 10, 11, 7); FCD_Custom20_Calc_Face_Tri(11, 10, 6, 8); FCD_Custom20_Calc_Face_Tri(11, 7, 6, 9); FCD_Custom20_Calc_Face_Tri(0, 3, 4, 10); FCD_Custom20_Calc_Face_Tri(0, 2, 3, 11); FCD_Custom20_Calc_Face_Tri(0, 4, 5, 12); FCD_Custom20_Calc_Face_Tri(3, 4, 8, 13); FCD_Custom20_Calc_Face_Tri(4, 5, 9, 14); FCD_Custom20_Calc_Face_Tri(4, 8, 9, 15); FCD_Custom20_Calc_Face_Tri(3, 7, 8, 16); FCD_Custom20_Calc_Face_Tri(2, 3, 7, 17); FCD_Custom20_Calc_Face_Tri(7, 8, 11, 18); FCD_Custom20_Calc_Face_Tri(8, 9, 11, 19); } } static void FCD_Custom20_Calc_Face_Tri(short n1, short n2, short n3, char idx) { float nx, ny, nz; float sx, sy, sz; float Dot; float temp; nx = xview[n1] + xview[n2]; nx = (nx + xview[n3]) / 3; ny = yview[n1] + yview[n2]; ny = (ny + yview[n3]) / 3; nz = zview[n1] + zview[n2]; nz = (nz + zview[n3]) / 3; sx = d - nx; sy = 0 - ny; sz = 0 - nz; sx = nx * sx; sy = ny * sy; sz = nz * sz; Dot = sx + sy; Dot = Dot + sz; visiblep[idx] = visible[idx]; //is vector facing away if (Dot < 0) { visible[idx] = 0; return; } visible[idx] = 1; temp = d - xview[n1]; zs[n1] = (zview[n1] / temp) * SCALE_3D; ys[n1] = (yview[n1] / temp) * SCALE_3D; xs[n1] = (xview[n1] / temp) * SCALE_3D; temp = d - xview[n2]; zs[n2] = (zview[n2] / temp) * SCALE_3D; ys[n2] = (yview[n2] / temp) * SCALE_3D; xs[n2] = (xview[n2] / temp) * SCALE_3D; temp = d - xview[n3]; zs[n3] = (zview[n3] / temp) * SCALE_3D; ys[n3] = (yview[n3] / temp) * SCALE_3D; xs[n3] = (xview[n3] / temp) * SCALE_3D; } static void FCD_Custom20_Calc_Face_Sq(short n1, short n2, short n3, short n4, char idx) { float temp; temp = d - xview[n1]; zs[n1] = (zview[n1] / temp) * SCALE_3D; ys[n1] = (yview[n1] / temp) * SCALE_3D; xs[n1] = (xview[n1] / temp) * SCALE_3D; temp = d - xview[n2]; zs[n2] = (zview[n2] / temp) * SCALE_3D; ys[n2] = (yview[n2] / temp) * SCALE_3D; xs[n2] = (xview[n2] / temp) * SCALE_3D; temp = d - xview[n3]; zs[n3] = (zview[n3] / temp) * SCALE_3D; ys[n3] = (yview[n3] / temp) * SCALE_3D; xs[n3] = (xview[n3] / temp) * SCALE_3D; temp = d - xview[n4]; zs[n4] = (zview[n4] / temp) * SCALE_3D; ys[n4] = (yview[n4] / temp) * SCALE_3D; xs[n4] = (xview[n4] / temp) * SCALE_3D; } static void FCD_Custom20_Draw_3D_Shape(char Colour) { if (Shape < 2) { FCD_Custom20_Draw_Face_Sq(0, 1, 2, 3, 0, Colour); } if (Shape == 2) { FCD_Custom20_Draw_Face_Sq(0, 1, 2, 3, 0, Colour); FCD_Custom20_Draw_Face_Sq(4, 5, 6, 7, 0, Colour); //Optimisation - Remaining 4 faces can be done using just 4 lines FCD_Custom20_Draw_Line (ysp[1], zsp[1], ysp[4], zsp[4], 0); FCD_Custom20_Draw_Line (ys[1], zs[1], ys[4], zs[4], Colour); FCD_Custom20_Draw_Line (ysp[0], zsp[0], ysp[5], zsp[5], 0); FCD_Custom20_Draw_Line (ys[0], zs[0], ys[5], zs[5], Colour); FCD_Custom20_Draw_Line (ysp[3], zsp[3], ysp[6], zsp[6], 0); FCD_Custom20_Draw_Line (ys[3], zs[3], ys[6], zs[6], Colour); FCD_Custom20_Draw_Line (ysp[2], zsp[2], ysp[7], zsp[7], 0); FCD_Custom20_Draw_Line (ys[2], zs[2], ys[7], zs[7], Colour); } if (Shape == 3) { //No optimisation available or visible mechanism cannot guarentee edges are not missing FCD_Custom20_Draw_Face_Tri(0, 1, 2, 0, Colour); FCD_Custom20_Draw_Face_Tri(0, 1, 5, 1, Colour); FCD_Custom20_Draw_Face_Tri(1, 10, 6, 2, Colour); FCD_Custom20_Draw_Face_Tri(5, 10, 9, 3, Colour); FCD_Custom20_Draw_Face_Tri(5, 1, 10, 4, Colour); FCD_Custom20_Draw_Face_Tri(1, 2, 6, 5, Colour); FCD_Custom20_Draw_Face_Tri(2, 7, 6, 6, Colour); FCD_Custom20_Draw_Face_Tri(9, 10, 11, 7, Colour); FCD_Custom20_Draw_Face_Tri(11, 10, 6, 8, Colour); FCD_Custom20_Draw_Face_Tri(11, 7, 6, 9, Colour); FCD_Custom20_Draw_Face_Tri(0, 3, 4, 10, Colour); FCD_Custom20_Draw_Face_Tri(0, 2, 3, 11, Colour); FCD_Custom20_Draw_Face_Tri(0, 4, 5, 12, Colour); FCD_Custom20_Draw_Face_Tri(3, 4, 8, 13, Colour); FCD_Custom20_Draw_Face_Tri(4, 5, 9, 14, Colour); FCD_Custom20_Draw_Face_Tri(4, 8, 9, 15, Colour); FCD_Custom20_Draw_Face_Tri(3, 7, 8, 16, Colour); FCD_Custom20_Draw_Face_Tri(2, 3, 7, 17, Colour); FCD_Custom20_Draw_Face_Tri(7, 8, 11, 18, Colour); FCD_Custom20_Draw_Face_Tri(8, 9, 11, 19, Colour); } } static void FCD_Custom20_Draw_Face_Tri(short n1, short n2, short n3, char idx, char Colour) { if (visiblep[idx]) { FCD_Custom20_Draw_Line (ysp[n1], zsp[n1], ysp[n2], zsp[n2], 0); FCD_Custom20_Draw_Line (ysp[n2], zsp[n2], ysp[n3], zsp[n3], 0); FCD_Custom20_Draw_Line (ysp[n3], zsp[n3], ysp[n1], zsp[n1], 0); } if (visible[idx]) { FCD_Custom20_Draw_Line (ys[n1], zs[n1], ys[n2], zs[n2], Colour); FCD_Custom20_Draw_Line (ys[n2], zs[n2], ys[n3], zs[n3], Colour); FCD_Custom20_Draw_Line (ys[n3], zs[n3], ys[n1], zs[n1], Colour); } } static void FCD_Custom20_Draw_Face_Sq(short n1, short n2, short n3, short n4, char idx, char Colour) { FCD_Custom20_Draw_Line (ysp[n1], zsp[n1], ysp[n2], zsp[n2], 0); FCD_Custom20_Draw_Line (ysp[n2], zsp[n2], ysp[n3], zsp[n3], 0); FCD_Custom20_Draw_Line (ysp[n3], zsp[n3], ysp[n4], zsp[n4], 0); FCD_Custom20_Draw_Line (ysp[n4], zsp[n4], ysp[n1], zsp[n1], 0); FCD_Custom20_Draw_Line (ys[n1], zs[n1], ys[n2], zs[n2], Colour); FCD_Custom20_Draw_Line (ys[n2], zs[n2], ys[n3], zs[n3], Colour); FCD_Custom20_Draw_Line (ys[n3], zs[n3], ys[n4], zs[n4], Colour); FCD_Custom20_Draw_Line (ys[n4], zs[n4], ys[n1], zs[n1], Colour); } static void FCD_Custom20_Rotate_3D_Shape() { short vertex; float xnew, ynew; float tempx, tempy; float coscalc[2], sincalc[2]; coscalc[0] = cos(eview); //View Elevation sincalc[0] = sin(eview); coscalc[1] = cos(DPHI); //Delta Phi - Rotation around Y sincalc[1] = sin(DPHI); for (vertex = 0; vertex < Vertex_Count; vertex++) { xsp[vertex] = xs[vertex]; ysp[vertex] = ys[vertex]; zsp[vertex] = zs[vertex]; xview[vertex] = coscalc[0] * x[vertex]; xview[vertex] = xview[vertex] + (sincalc[0] * z[vertex]); yview[vertex] = y[vertex]; zview[vertex] = -sincalc[0] * x[vertex]; zview[vertex] = zview[vertex] + (coscalc[0] * z[vertex]); xnew = coscalc[1] * x[vertex]; xnew = xnew - (sincalc[1] * y[vertex]); ynew = sincalc[1] * x[vertex]; ynew = ynew + (coscalc[1] * y[vertex]); x[vertex] = xnew; y[vertex] = ynew; } eview = eview + (DPHI / 2); } static void FCD_Custom20_Draw_Text(char* String, char MSZ_String, short X, short Y, char Font, char Transparent, char FColour, char BColour) { char xpix, ypix, pos_Str, length_Str, xcount, ycount, height, width, i; char Fontwidth = 1; //First we assume small font char Fontheight = 1; unsigned int count, position; char temp[6]; temp[5] = 0x00; //Spacing Line length_Str = strlen(String); //Get length of string if (Font == 1) //Double Height Sizes //Double Width { Fontwidth = 2; } if (Font == 2) //Double Height and Width Sizes { Fontwidth = 2; Fontheight = 2; } if (Font == 3) //Double Height Sizes { Fontheight = 2; } xcount = 0; for (i=0;i> 4); AD1CON1bits.ADON = 0; //if data is valid if (retval < 62) return TLUT[retval]; return 0; } static char FCD_Custom20_Get_Rev_Count() { return REVS; } static void FCD_Custom20_Update_Time_Date() { int Yr, MonDat, WkHr, MinSec; while(RCFGCALbits.RTCSYNC==1); //wait for RTCSYNC bit to become ?0? RCFGCALbits.RTCPTR = 3; //points to the Year register Yr = RTCVAL; MonDat = RTCVAL; WkHr = RTCVAL; MinSec = RTCVAL; // read the device value YEAR = Yr & 0x00FF; MONTH = MonDat >> 8; DAY = MonDat & 0x00FF; WDAY = WkHr >> 8; HOUR = WkHr & 0x00FF; MIN = MinSec >> 8; SEC = MinSec & 0x00FF; YEAR = (10 * (YEAR >> 4)) + (YEAR & 0x0F); MONTH = (10 * (MONTH >> 4)) + (MONTH & 0x0F); DAY = (10 * (DAY >> 4)) + (DAY & 0x0F); WDAY = (10 * (WDAY >> 4)) + (WDAY & 0x0F); HOUR = (10 * (HOUR >> 4)) + (HOUR & 0x0F); MIN = (10 * (MIN >> 4)) + (MIN & 0x0F); SEC = (10 * (SEC >> 4)) + (SEC & 0x0F); } static char FCD_Custom20_Read_Time_Date(char selection) { switch(selection) { case 0: return SEC; case 1: return MIN; case 2: return HOUR; case 3: return WDAY; case 4: return DAY; case 5: return MONTH; case 6: return YEAR; } return 0; } static void FCD_Custom20_Timer_Tick() { FCV_TICK++; if (FCV_TICK == 100) { FCV_TICK = 0; REVS = REVCNT; REVCNT = 0; FCV_REV2 = FCV_REV; FCV_REV = 0; FCV_SEC++; if (FCV_SEC == 60) { FCV_SEC = 0; FCV_MIN++; if (FCV_MIN == 60) { FCV_MIN = 0; FCV_HOUR++; if (FCV_HOUR == 24) { FCV_HOUR = 0; FCV_DAY++; } } } } } //Macro implementations int main() { //Initialisation AD1PCFGL = 0xffff; /* // Configure Oscillator to operate the device at 40Mhz // Fosc= Fin*M/(N1*N2), Fcy=Fosc/2 // Fosc= 10M*32/(2*2)=80Mhz for 8M input clock PLLFBD=30; // M=32 CLKDIVbits.PLLPOST=0; // N1=2 CLKDIVbits.PLLPRE=0; // N2=2 // Clock switching to incorporate PLL __builtin_write_OSCCONH(0x03); // Initiate Clock Switch to Primary // Oscillator with PLL (NOSC=0b011) __builtin_write_OSCCONL(0x01); // Start clock switching while (OSCCONbits.COSC != 0b011); // Wait for Clock switch to occur // Wait for PLL to lock while(OSCCONbits.LOCK!=1) {}; */ EnableSecOsc(); // Enable the 32.768kHz Secondary oscillator //Configure Ports TRISB = 0xFF9A; PORTB = 0x0000; TRISC = 0xFF00; //Lower 8 Bits - LED Port PORTC = 0x00FF; //Configure Peripherals RPINR0 = 0x0700; //INT1 - RP7 - RB7 //RPINR18 = 0x1F0E; //UART1 RX - RP14 - RB14 //RPOR1 = 0x1200; //OC1 - RP3 - RB3 //RPOR0 = 0x0300; //UART1 TX - RP1 - RB1 //Timer PWM Interrupt //Interrupt: Enable TMR1 T1CON = ((T1CON & 0xfffd) | 0x8000); T1CON &= 0xff0f; PR1 = 0xFFFF; IEC0bits.T1IE = 1; //Hall Effect Interrupt //Interrupt: Enable INT0 INTCON2bits.INT0EP = 0; IEC0bits.INT0IE = 1; //RTCC /* asm("MOV #0x55,W0"); asm("MOV W0,NVMKEY"); // Write the 0x55 key asm("MOV #0xAA,W1"); asm("MOV W1,NVMKEY"); // Write the 0xAA key RCFGCALbits.RTCWREN = 1; RTCCOff(); //disable the RTCC peripheral PADCFG1 = 0x0000; //RTCC pin pad conected to Alarm // Enable the RTCC interrupt IFS3bits.RTCIF = 0; //clear the RTCC interrupt flag IEC3bits.RTCIE = 1; //enable the RTCC interrupt // Configure the alarm settings/ ALCFGRPTbits.CHIME = 0; //no rolloever of the repeat count ALCFGRPTbits.AMASK = 0; //alarm mask configuration bits ALCFGRPTbits.ARPT = 0; //alarm repeat counter value bits RCFGCALbits.RTCOE = 1; //enable RTCC output // Load the initial values to the RTCC value registers RCFGCALbits.RTCPTR = 3; //point to Year register RTCVAL = 0x0000; //Year RTCVAL = 0x0000; //Month & Day RTCVAL = 0x0000; //WkDay & Hour RTCVAL = 0x0000; //Min & Sec RCFGCALbits.CAL=0x0000; //No calibration ALCFGRPTbits.ALRMPTR = 2; //Point to Month/Day register ALRMVAL = 0x0000; //load month & day ALRMVAL = 0x0000; //load weekday & hour ALRMVAL = 0x0000; //load minute & seconds ALCFGRPTbits.ALRMEN = 1; //enable the alarm RTCCOn(); //enable RTCC peripheral RTCCLock(); //lock the RTCC value registers */ //Interrupt: Enable TMR3 @ 100Hz Exactly T3CON = ((T3CON & 0xfffd) | 0x8000); T3CON = ((T3CON & 0xff0f) | 0x0010); PR3 = 50000-1; IEC0bits.T3IE = 1; //UART 1 /* U1BRG = SPBRG_VAL; //Set the baud rate 115200bps U1STA = 0; //Reset the UART U1MODE = 0; //Reset the mode U1MODEbits.UARTEN = 1; //turn on serial interCalc_Face_Tri 1 IEC0bits.U1RXIE = 1; //Enable UART RX Interrupt */ //Interrupt initialisation code //Calculation //Calculation: // seg = 0 FCV_SEG = 0; //Loop //Loop: While 1 while (1) { //Clear Display //Call Component Macro: Custom2(0)::Clear_Display FCD_Custom20_Clear_Display(); //Call Component Macro //Call Component Macro: Custom2(0)::Modify_Pixel_XY(0, 23, 4) FCD_Custom20_Modify_Pixel_XY(0, 23, 4); //Call Component Macro //Call Component Macro: Custom2(0)::Modify_Pixel_XY(23, 0, 2) FCD_Custom20_Modify_Pixel_XY(23, 0, 2); //Call Component Macro //Call Component Macro: Custom2(0)::Draw_Arc(0, 239, 0, 1) FCD_Custom20_Draw_Arc(0, 239, 0, 1); //Call Component Macro //Call Component Macro: Custom2(0)::Setup_3D_Shape(shape) FCD_Custom20_Setup_3D_Shape(FCV_SHAPE); //Loop //Loop: Loop 100 times for (FCLV_LOOP1=0; FCLV_LOOP1<100; FCLV_LOOP1++) { //String Manipulation //String Manipulation: // tst = ToString$(rev2) FCI_TOSTRING(FCV_REV2,FCV_TST,FCSZ_TST); //Call Component Macro //Call Component Macro: Custom2(0)::Draw_Text_Polar(tst, 6, 2, 0, 0, 1) FCD_Custom20_Draw_Text_Polar(FCV_TST,FCSZ_TST, 6, 2, 0, 0, 1); //Calculation //Calculation: // x = 239 - (Sec * 4) FCV_X = 239 - (FCV_SEC * 4); //Call Component Macro //Call Component Macro: Custom2(0)::Draw_Axle(x, 1, 8, 2) FCD_Custom20_Draw_Axle(FCV_X, 1, 8, 2); //Calculation //Calculation: // y = 239 - (Tick * 2.4) FCV_Y = 239 - (FCV_TICK * 2.4); //Call Component Macro //Call Component Macro: Custom2(0)::Draw_Axle(y, 1, 8, 7) FCD_Custom20_Draw_Axle(FCV_Y, 1, 8, 7); //Call Component Macro //Call Component Macro: Custom2(0)::Rotate_3D_Shape FCD_Custom20_Rotate_3D_Shape(); //Call Component Macro //Call Component Macro: Custom2(0)::Calc_3D_Shape FCD_Custom20_Calc_3D_Shape(); //Call Component Macro //Call Component Macro: Custom2(0)::Draw_3D_Shape(4) FCD_Custom20_Draw_3D_Shape(4); //Delay //Delay: 10 ms delay_ms(10); //Call Component Macro //Call Component Macro: Custom2(0)::Draw_Axle(x, 1, 8, 0) FCD_Custom20_Draw_Axle(FCV_X, 1, 8, 0); //Call Component Macro //Call Component Macro: Custom2(0)::Draw_Axle(y, 1, 8, 0) FCD_Custom20_Draw_Axle(FCV_Y, 1, 8, 0); //Calculation //Calculation: // rev = rev + 1 FCV_REV = FCV_REV + 1; } //Calculation //Calculation: // shape = (shape + 1) MOD 4 FCV_SHAPE = (FCV_SHAPE + 1) % 4; } mainendloop: goto mainendloop; return 0; } //Handler code for [TMR1] void _ISR _T1Interrupt(void) { FCD_Custom20_PWM_Control(); IFS0bits.T1IF = 0; } //Handler code for [INT0] void _ISR _INT0Interrupt(void) { FCD_Custom20_SpinSync(); IFS0bits.INT0IF = 0; } /* //Handler code for [RTCC] void _ISR _RTCCInterrupt(void) { FCD_Custom20_Update_Time_Date(); IFS3bits.RTCIF = 0; } */ //Handler code for [TMR3] RTCC Replacement void _ISR _T3Interrupt(void) { IFS0bits.T3IF = 0; FCD_Custom20_Timer_Tick(); }