int main() { Set_Mode(MCGA); //set video mode 13h (MCGA) int i,j; //counters if(1) { owenmap(); exit(0);} //first, I'll draw the pattern directly to the screen... for(i=0;i<SCREEN_WIDTH;i++) for(j=0;j<SCREEN_HEIGHT;j++) Plot_Pixel(i,j,COLOR); getch(); //wait for a keypress //and now I'll draw to a buffer and then copy that to scrn Create_DB(); //allocate mem for a double buffer Clear_Scrn(0); //clear screen to 0(black) Clear_Scrn_DB(0); //clear the DB to 0 for(i=0;i<SCREEN_WIDTH;i++) for(j=0;j<SCREEN_HEIGHT;j++) Plot_Pixel_DB(i,j,COLOR_DB); Show_DB(); getch(); Delete_DB(); //free the Db's Memory Set_Mode(TEXT); //return to text mode return 0; }
//--------------------------------------------------------- void CVIEW_Map_Control::On_Mouse_MUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } _Draw_Inverse(m_Mouse_Down, event.GetPosition()); m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; switch( m_Mode ) { //----------------------------------------------------- case MAP_MODE_SELECT: break; //----------------------------------------------------- case MAP_MODE_DISTANCE: break; //----------------------------------------------------- case MAP_MODE_ZOOM: break; //----------------------------------------------------- case MAP_MODE_PAN: break; //----------------------------------------------------- case MAP_MODE_PAN_DOWN: Set_Mode(MAP_MODE_ZOOM); _Move(m_Mouse_Down, event.GetPosition()); break; } }
//--------------------------------------------------------- void CVIEW_Map_Control::On_Mouse_LUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } //----------------------------------------------------- if( m_Mode != MAP_MODE_SELECT && (event.ControlDown() || event.AltDown()) ) // clipboard copy ? { return; } //----------------------------------------------------- _Draw_Inverse(m_Mouse_Down, event.GetPosition()); m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; switch( m_Mode ) { //----------------------------------------------------- case MAP_MODE_SELECT: if( g_pTool ) { g_pTool->Execute(_Get_Client2World(event.GetPosition()), TOOL_INTERACTIVE_LUP, GET_KEYS(event)); } else if( m_pMap->Find_Layer(Get_Active_Layer()) ) { Get_Active_Layer()->Edit_On_Mouse_Up(_Get_Client2World(event.GetPosition()), _Get_Client2World(1.0), GET_KEYS(event)|TOOL_INTERACTIVE_KEY_LEFT); } break; //----------------------------------------------------- case MAP_MODE_DISTANCE: _Distance_Add(event.GetPosition()); break; //----------------------------------------------------- case MAP_MODE_ZOOM: _Zoom(m_Mouse_Down, event.GetPosition()); break; //----------------------------------------------------- case MAP_MODE_PAN: break; //----------------------------------------------------- case MAP_MODE_PAN_DOWN: Set_Mode(MAP_MODE_PAN); _Move(m_Mouse_Down, event.GetPosition()); break; } }
//--------------------------------------------------------- CVIEW_Map_Control::CVIEW_Map_Control(CVIEW_Map *pParent, CWKSP_Map *pMap) : wxPanel(pParent, -1, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE) { SYS_Set_Color_BG_Window(this); m_pParent = (CVIEW_Map *)pParent; m_pMap = pMap; m_Mode = -1; Set_Mode(MAP_MODE_ZOOM); m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; }
int main() { /*for(int i=0;i<1000;i++) { cout << "Isqrt(" << i << ") = " << Isqrt(i) << endl; if(!(i%25)) getch(); }*/ Set_Mode(MCGA); //set video mode 13h (MCGA) int i,j; //counters //first, I'll draw the pattern directly to the screen... for(i=0;i<SCREEN_WIDTH;i++) for(j=0;j<SCREEN_HEIGHT;j++) { Plot_Pixel(i,j,COLOR); //cout << "(x,y): (" << i << "," << j << ")." << endl; //getch(); } getch(); //wait for a keypress //and now I'll draw to a buffer and then copy that to scrn Create_DB(); //allocate mem for a double buffer Clear_Scrn(0); //clear screen to 0(black) Clear_Scrn_DB(0); //clear the DB to 0 for(i=0;i<SCREEN_WIDTH;i++) for(j=0;j<SCREEN_HEIGHT;j++) Plot_Pixel_DB(i,j,COLOR_DB); Show_DB(); getch(); Delete_DB(); //free the Db's Memory Set_Mode(TEXT); //return to text mode return 0; }
//--------------------------------------------------------- void CVIEW_Map_Control::On_Mouse_MDown(wxMouseEvent &event) { bool bCaptureMouse = true; m_Mouse_Down = m_Mouse_Move = event.GetPosition(); switch( m_Mode ) { //----------------------------------------------------- case MAP_MODE_SELECT: if( g_pTool ) { g_pTool->Execute(_Get_Client2World(event.GetPosition()), TOOL_INTERACTIVE_MDOWN, GET_KEYS(event)); } break; //----------------------------------------------------- case MAP_MODE_DISTANCE: break; //----------------------------------------------------- case MAP_MODE_ZOOM: m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; Set_Mode(MAP_MODE_PAN_DOWN); break; //----------------------------------------------------- case MAP_MODE_PAN: break; //----------------------------------------------------- case MAP_MODE_PAN_DOWN: m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; break; } //----------------------------------------------------- if( bCaptureMouse && !HasCapture() ) { CaptureMouse(); } event.Skip(); }
//--------------------------------------------------------- void CVIEW_Map_Control::On_Mouse_LDown(wxMouseEvent &event) { m_Mouse_Down = m_Mouse_Move = event.GetPosition(); //----------------------------------------------------- if( m_Mode != MAP_MODE_SELECT ) // clipboard copy ? { if( event.ControlDown() ) { m_pMap->SaveAs_Image_Clipboard(false); return; } if( event.AltDown() ) { m_pMap->SaveAs_Image_Clipboard(GetClientSize().x, GetClientSize().y, -1); return; } } //----------------------------------------------------- bool bCaptureMouse = true; switch( m_Mode ) { //----------------------------------------------------- case MAP_MODE_SELECT: if( g_pTool && g_pTool->is_Interactive() ) { m_Drag_Mode = ((CSG_Tool_Interactive *)g_pTool->Get_Tool())->Get_Drag_Mode(); bCaptureMouse = !g_pTool->Execute(_Get_Client2World(event.GetPosition()), TOOL_INTERACTIVE_LDOWN, GET_KEYS(event)); } else if( m_pMap->Find_Layer(Get_Active_Layer()) ) { switch( Get_Active_Layer()->Get_Type() ) { default: m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; break; case WKSP_ITEM_Grid: case WKSP_ITEM_PointCloud: m_Drag_Mode = TOOL_INTERACTIVE_DRAG_BOX; break; case WKSP_ITEM_Shapes: m_Drag_Mode = ((CWKSP_Shapes *)Get_Active_Layer())->is_Editing() ? TOOL_INTERACTIVE_DRAG_NONE : TOOL_INTERACTIVE_DRAG_BOX; break; } Get_Active_Layer()->Edit_On_Mouse_Down(_Get_Client2World(event.GetPosition()), _Get_Client2World(1.0), GET_KEYS(event)); } break; //----------------------------------------------------- case MAP_MODE_DISTANCE: m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; break; //----------------------------------------------------- case MAP_MODE_ZOOM: m_Drag_Mode = TOOL_INTERACTIVE_DRAG_BOX; break; //----------------------------------------------------- case MAP_MODE_PAN: m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; Set_Mode(MAP_MODE_PAN_DOWN); break; //----------------------------------------------------- case MAP_MODE_PAN_DOWN: m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; break; } //----------------------------------------------------- if( bCaptureMouse && !HasCapture() ) { CaptureMouse(); } event.Skip(); }
/* * @brief Initialization is used to configure all of the registers of the microcontroller * Steps: * 1) Initialize CC3000 * 2) Set MUX Select_A to LOW, so we can send the Kill command from Atmega TX line * (C0 input on MUX) * 3) Set Mode to Safety Mode * 4) Set MUX Select A to HIGH, so we get into Autonomous mode by default * (C1 input on MUX) */ inline void Initialization (void) { #ifdef WATCHDOG_ENABLED wdt_enable(WDTO_8S); // WDTO_8S means set the watchdog to 8 seconds. #endif //Turn on the Power LED to identify that the device is on. // [UNUSED] DDRC |= (1 << DDC7); //STATUS LED //Set up the LEDs for WLAN_ON and DHCP: DDRC |= (1 << DDC6); //WLAN_INIT LED DDRC |= (1 << DDC7); //DHCP_Complete LED. This will turn on and very slowly blink DDRB |= (1 << DDB7); // MUX Select line, setting as output. DDRE |= (1 << DDE2); // DDRF set outbound for Safe Mode LED DDRD |= (1 << DDD6); // DDRF set outbound for Manual Mode LED DDRD |= (1 << DDD4); // DDRF set outbound for Auto Mode LED PORTF |= (1 << PF0); // Extra GPIO Pin PORTF |= (1 << PF1); // Extra GPIO Pin #ifndef SKIP_BOOT DDRB |= (1 << DDB4); DDRD |= (1 << DDD7); DDRD |= (1 << DDD6); PORTB |= (1 << PB4); _delay_ms(200); PORTD |= (1 << PD7); _delay_ms(200); PORTD |= (1 << PD6); _delay_ms(200); PORTB &= ~(1 << PB4); _delay_ms(200); PORTD &= ~(1 << PD7); _delay_ms(200); PORTD &= ~(1 << PD6); #endif _delay_ms(500); PORTF &= ~(1 << PF0); PORTF &= ~(1 << PF1); // #ifdef ENERGY_ANALYSIS_ENABLED // //Enable Timer/Counter0 Interrupt on compare match of OCR0A: // TIMSK0 = (1 << OCIE0A); // //Set the Output Compare Register for the timer to compare against: // OCR0A = Energy_Analysis_Interval; // //Configure the ADC to have the reference pin be AREF on pin 21, and make sure everything is set to defaults: // ADMUX = 0x00; // //Enable the Analog to Digital Conversion (ADC): // ADCSRA = (1 << ADEN); //25 Clock cycles to initialize. // #endif #ifdef CC3000_ENABLED //Enable the CC3000, and setup the SPI configurations. init_spi(); //Set up the CC3000 API for communication. wlan_init(CC3000_Unsynch_Call_Back, Send_WLFW_Patch, Send_Driver_Patch, Send_Boot_Loader_Patch, Read_WLAN_Interrupt_Pin, WLAN_Interrupt_Enable, WLAN_Interrupt_Disable, Write_WLAN_Pin); PORTB |= (1 << PB6); //Set the WLAN_INIT LED on. sei(); //Enable the CC3000, and wait for initialization process to finish. wlan_start(0); wlan_set_event_mask(HCI_EVNT_WLAN_KEEPALIVE|HCI_EVNT_WLAN_UNSOL_INIT|HCI_EVNT_WLAN_ASYNC_PING_REPORT); //Make sure we disconnect from any previous routers before we connect to a new one to prevent confusion on the device. wlan_disconnect(); wlan_connect(WLAN_SEC_UNSEC, ROUTER_SSID, SSID_LENGTH, NULL, NULL, 0); while(!DHCP_Complete) { _delay_ms(1000); } #ifdef WATCHDOG_ENABLED wdt_reset(); #endif //Bind a socket to receive data: //sockaddr Mission_Control_Address; memset((char *) &Mission_Control_Address, 0, sizeof(Mission_Control_Address)); Mission_Control_Address.sa_family = AF_INET; //The Source Port: Mission_Control_Address.sa_data[0] = (char)HEX_PORT_1; //(char)0x09; Mission_Control_Address.sa_data[1] = (char)HEX_PORT_2; //(char)0x56; //Configure the socket to not time out to keep the connection active. //-------------------------------------------------------------------- unsigned long aucDHCP = 14400; unsigned long aucARP = 3600; unsigned long aucKeepalive = 10; unsigned long aucInactivity = 0; netapp_timeout_values(&aucDHCP, &aucARP, &aucKeepalive, &aucInactivity); //TODO: //Should check the CC3000's profiles. In the case that there are no profiles found, then //inform the PC system, or use an LED. //Open a UDP socket that grabs datagram: Socket_Handle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); switch(Socket_Handle) { case -1: //Error //Flag somehow. break; default: //Success //Set the socket configuration for blocking (since it is the only thing that is allowed). switch( bind(Socket_Handle, &Mission_Control_Address, sizeof(sockaddr))) { case -1: //Flag as ERROR. break; default: //Flag as good. break; } break; } #endif // NEED TO SETUP A QUICK REMOVAL FLAG FOR THIS CODE TO TEST THE CC3000. // #ifdef MOTOR_CONTROL_FLAG // Set up our Motor Controller Selection lines and the output for the RS232 lines: // DDRD |= (1 << DDD3) | (1 << DDD4) | (1 << DDD5); DDRD |= (1 << DDD3) | (1 << DDD5); // Initialize the UART (RS-232 communications) for the motor controller interface: // Set the Baud rate to 115200 bits/s. ((System Oscillator clock frequency / (2 * BAUD) ) - 1) // NOTE: The value may not be correct, according to the data sheet (pg. 213). // With the value 16, the error is 2.1% (lower than 8, being -3.5%). // This comes from util/setbaud.h UBRR1H = UBRRH_VALUE; /*Set baud rate*/ UBRR1L = UBRRL_VALUE; /*Set baud rate*/ //Defined in util/setbaud.h: #if USE_2X UCSR1A |= (1 << U2X1); //Double the baud rate for asynchronous communication. #else UCSR1A &= ~(1 << U2X1); #endif // Set to no parity and in Asynchronous mode. // 1 Stop bit. // 1 Start bit. // Set to 8-bit data. UCSR1C |= (1 << UCSZ11) | (1 << UCSZ10); //Enable the Rx and Tx lines. UCSR1B |= (1 << TXEN1); #ifdef TWI_ENABLED //Set the SCL frequency to 200 KHz. From the equation: f(SCL) = F_CPU/(16 + (2*TWBR) * (4^TWPS)) TWBR = 12; DDRB |= (1 << DDB4); //Setup PortB4 as the TWI error LED. #endif //End TWI_ENABLED _delay_ms(1000); //Wait for one second for the RoboteQs to finish booting. Set_Mode(SAFETY_MODE); // Set to Safe Mode to send Kill Command to Roboteq's Set_Mode(AUTONOMOUS_MODE); #ifdef ROUTER_WATCHDOG_ENABLED Count = 0; //Clear the Count variable out. TCNT1 = 0; //Clear the TCNT register. TCCR1B = (1 << CS12) | (1 << CS10); //Set the prescaler for 1024. TIMSK1 = (1 << OCIE1A); //Enable output compare for 1A. OCR1A = 39063; //Set the system to interrupt every 5 seconds. //OCR1A = (Multiplier) * (F_CPU) / (Prescaler) //39063 = (5) * (8000000) / (1024) #endif }
/************************************************************** * 函数说明:光传感器设置函数 * **************************************************************/ void SetSensor(void) { char *str_AV = (char *) malloc(5); char *str_TV = (char *) malloc(8); char *str_ISO = (char *) malloc(5); char *str_coef = (char *) malloc(5); char *str_HDR = (char *) malloc(2); char *str_ND = (char *) malloc(3); uint8 AV_NO = 1; uint8 esc_flag = 0; uint8 time_cnt = 0; float coef,AV; uint32 int_TV; uint16 ISO; uint8 HDR,ND; Set_Mode(OFF); ISO = 100 << e_ISO; itoa(ISO,str_ISO); Disp_Str1(0,5,str_ISO); AV = e_AV; ftoa(AV,1,str_AV); Disp_Str1(0,1,str_AV); coef = e_coef; ftoa(coef,2,str_coef); Disp_Str1(2,5,str_coef); HDR = e_HDR; itoa(HDR,str_HDR); Disp_Str1(3,3,str_HDR); ND = e_ND; itoa(ND,str_ND); Disp_Str1(3,6,str_ND); while(!esc_flag) { if(time_10ms) //10ms定时扫描键盘 { time_10ms = 0; key_value= Read_keyboard(); if(key_value != No_key) { switch(key_value) { case Esc: if(MenuPoint[UserChooseR].ParentMenus != NULL) { MenuPoint = MenuPoint[UserChooseR].ParentMenus; UserChooseR = 1; UserChooseC = 0; //DisplayStart = 0; } esc_flag = 1; break; case OK: //Set_Mode(); break; case 1: AV_NO++; if(AV_NO==8) { AV_NO = 1; } break; case 3: e_ISO++; if(e_ISO == 6) {e_ISO = 0;} ISO = 100 << e_ISO; break; case 4: coef -= 0.05; break; case 6: coef += 0.05; break; case 7: HDR++; if(HDR == 7) { HDR = 0; } break; case 9: ND++; if(ND == 11) { ND = 0; } default: break; } switch(AV_NO) { case 1: AV = 2.8; break; case 2: AV = 4.0; break; case 3: AV = 5.6; break; case 4: AV = 8.0; break; case 5: AV = 11; break; case 6: AV = 16; break; case 7: AV = 22; break; default: break; } e_AV = AV; ftoa(AV,1,str_AV); Disp_Str(0,1," "); Disp_Str1(0,1,str_AV); e_coef = coef; ftoa(coef,2,str_coef); Disp_Str1(2,5,str_coef); itoa(ISO,str_ISO); Disp_Str(0,5," "); Disp_Str1(0,5,str_ISO); e_HDR = HDR; itoa(HDR,str_HDR); Disp_Str1(3,3,str_HDR); e_ND = ND; itoa(ND,str_ND); Disp_Str(3,6," "); Disp_Str1(3,6,str_ND); } if(++time_cnt == 100) { time_cnt = 0; //get_lux(); //Disp_Str1(0,4,lux_value); int_TV = Get_TV(); ltoa(int_TV,str_TV); Disp_Str(1,3," "); Disp_Str1(1,3,str_TV); } } } free(str_AV); free(str_TV); free(str_ISO); free(str_coef); free(str_HDR); free(str_ND); Set_Mode(ON); Clear_Scr(); ShowMenu(); }
/************************************************************** * 函数说明:状态显示函数 * **************************************************************/ void ShowState(void) { char *s_taken = (char *) malloc(5); char *s_left = (char *) malloc(5); char *s_dist = (char *) malloc(5); uint8 time_cnt = 0; uint8 esc_flag = 0; //UserChooseR = 0; //Set_Cursor(0,0); itoa(photo_taken,s_taken); Disp_Str1(0,2,s_taken); itoa(photo_left,s_left); Disp_Str1(0,6,s_left); itoa(now_dist,s_dist); Disp_Str1(1,5,s_dist); Set_Mode(OFF); while(!esc_flag) { if(time_10ms) //10ms定时扫描键盘 { time_10ms = 0; key_value= Read_keyboard(); if(key_value == Esc) { Set_Mode(ON); if(MenuPoint[UserChooseR].ParentMenus != NULL) { MenuPoint = MenuPoint[UserChooseR].ParentMenus; UserChooseR = 1; UserChooseC = 1; } esc_flag = 1; } if(++time_cnt == 100) { time_cnt = 0; //s_taken = Int2Str(photo_taken); itoa(photo_taken,s_taken); Disp_Str(0,2," "); Disp_Str1(0,2,s_taken); //s_left = Int2Str(photo_left); itoa(photo_left,s_left); Disp_Str(0,6," "); Disp_Str1(0,6,s_left); //dist_str = Int2Str(now_dist); itoa(now_dist,s_dist); Disp_Str(1,5," "); Disp_Str1(1,5,s_dist); //delay_ms(50); } } } free(s_taken); free(s_left); free(s_dist); Clear_Scr(); ShowMenu(); }
int owenmap() { int i,j,k,color; float x,y, u,v, mag, utemp, cx, cy, l; float xmin; float ymin, yrange; ///////////////////////////////////////////////////////// ///////////some interesting places to look/////////////// ///////////////////////////////////////////////////////// /////////// un-comment as necessary... ////////////////// ///////////////////////////////////////////////////////// //original coords float xrange = 3.5, xcenter = -0.5, ycenter=0.0; int movieframes = 60; float framechange = 0.10; //zoom in on one of the baby mandelbrots near the top //float xrange = .03, xcenter = -0.157, ycenter=1.033; //int movieframes = 80; //float framechange = 0.015; //zoom in on a 7-bulb on the side of the main mandelbrot //float xrange = .20, xcenter = -0.65, ycenter=0.435; //int movieframes = 100; //float framechange = 0.0015; //right end of mandelbrot set //float xrange = .25, xcenter = 0.325, ycenter=0.0; //int movieframes = 120; //float framechange = 0.002; ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //code that computes yscale, minima, etc. xmin = xcenter - 0.5 * xrange; yrange = 0.8 * xrange; ymin = ycenter - 0.5 * yrange; //first, I'll draw the pattern directly to the screen... for(i=0;i<SCREEN_WIDTH;i++) { for(j=0;j<SCREEN_HEIGHT;j++) { x=(float)i/SCREEN_WIDTH; y=1.0 - (float)j/SCREEN_HEIGHT; x=xmin+(x*xrange); y=ymin+(y*yrange); u=0; v=0; mag=u*u+v*v; ////////////////////////// //begin mandelbrot program for(k=0;(k<100)&&(mag<=25);k++) { // z = z^2 + c; c = x + yi // so u = u*u - v*v + x; // and v = 2*u*v + y; utemp = u; u = u*u - v*v + x; v = 2*v*utemp + y; mag = u*u + v*v; } if (k >= 99) color = 0; else color = (int) 32 + (k*64/99); //end mandelbrot program //////////////////////// Plot_Pixel(i,j,color); } } getch(); cx = xcenter; cy = ycenter; xrange = 3.5; xcenter = 0; ycenter=0.0; //code that computes yscale, minima, etc. xmin = xcenter - 0.5 * xrange; yrange = 0.8 * xrange; ymin = ycenter - 0.5 * yrange; Create_DB(); for(l=-(movieframes/2)*framechange;l<(framechange*movieframes/2);l+=framechange) { //now let's do it again for(i=0;i<SCREEN_WIDTH;i++) { for(j=0;j<SCREEN_HEIGHT;j++) { x=(float)i/SCREEN_WIDTH; y=1.0 - (float)j/SCREEN_HEIGHT; x=xmin+(x*xrange); y=ymin+(y*yrange); //note that in julia program, //u and v are initialized to x and y //rather than 0 and 0. u=x; v=y; mag=u*u+v*v; ////////////////////////// //begin julia program for(k=0;(k<100)&&(mag<=25);k++) { // z = z^2 + c; c = cx + cyi // so u = u*u - v*v + cx; // and v = 2*u*v + cy; utemp = u; u = u*u - v*v + cx+l; v = 2*v*utemp + cy; mag = u*u + v*v; } if (k >= 99) color = 0; else color = (int) 32 + (k*64/99); //end julia program //////////////////////// Plot_Pixel_DB(i,j,color); } } Wait_VTrace(); //wait until the electron beam moves from //corner to corner and isn't drawing anything Show_DB(); //then show the buffer if(kbhit()) { while(kbhit()) getch(); getch(); } } getch(); Delete_DB(); Set_Mode(TEXT); //return to text mode return 0; }