int main() { HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); if (SUCCEEDED(hr)) { IPingable * ptrPingable; HRESULT hr = CoCreateInstance(CLSID_CoPingEngine, NULL, CLSCTX_LOCAL_SERVER, IID_IPingable, reinterpret_cast<void**>(&ptrPingable)); if (SUCCEEDED(hr)) { ptrPingable->Initialize(); StatusResponse status; ptrPingable->Ping(12345, &status); printf("Status for ping code 12345: %d %S\n", status.Code, status.Description); ptrPingable->Ping(777, &status); printf("Status for ping code 777: %d %S\n", status.Code, status.Description); ptrPingable->Ping(1800, &status); printf("Status for ping code 1800: %d %S\n", status.Code, status.Description); CComVariant history; hr = ptrPingable->RetrieveHistory(&history); if (SUCCEEDED(hr)) { printHistory(history); } else { DisplayStatus(TEXT("RetrieveHistory failed: \n"), hr); } // Try creating a larger history printf("Sending more pings...\n"); for (int i = 0; i < 16; i++) { ptrPingable->Ping(i, &status); } hr = ptrPingable->RetrieveHistory(&history); if (SUCCEEDED(hr)) { printHistory(history); } else { DisplayStatus(TEXT("RetrieveHistory failed: \n"), hr); } SysFreeString(status.Description); ptrPingable->Release(); } else { DisplayStatus(TEXT("CoCreateInstance(CoPingEngine) failed: "), hr); } CoUninitialize(); } else { DisplayStatus(TEXT("CoInitializeEx failed: "), hr); } return 0; }
void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent& event ) { if( event.ShiftDown() ) { if( event.GetWheelRotation() < 0 ) SetView3D( WXK_UP ); // move up else SetView3D( WXK_DOWN ); // move down } else if( event.ControlDown() ) { if( event.GetWheelRotation() > 0 ) SetView3D( WXK_RIGHT ); // move right else SetView3D( WXK_LEFT ); // move left } else { if( event.GetWheelRotation() > 0 ) { GetPrm3DVisu().m_Zoom /= 1.4; if( GetPrm3DVisu().m_Zoom <= 0.01 ) GetPrm3DVisu().m_Zoom = 0.01; } else GetPrm3DVisu().m_Zoom *= 1.4; DisplayStatus(); Refresh( false ); } GetPrm3DVisu().m_Beginx = event.GetX(); GetPrm3DVisu().m_Beginy = event.GetY(); }
EDA_3D_CANVAS::EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList ) : wxGLCanvas( parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE ) { m_init = false; m_reportWarnings = true; m_shadow_init = false; // set an invalide value to not yet initialized indexes managing // textures created to enhance 3D rendering m_text_pcb = m_text_silk = INVALID_INDEX; m_text_fake_shadow_front = INVALID_INDEX; m_text_fake_shadow_back = INVALID_INDEX; m_text_fake_shadow_board = INVALID_INDEX; // position of the front and back layers // (will be initialized to a better value later) m_ZBottom = 0.0; m_ZTop = 0.0; m_lightPos = S3D_VERTEX(0.0f, 0.0f, 30.0f); // Clear all gl list identifiers: for( int ii = GL_ID_BEGIN; ii < GL_ID_END; ii++ ) m_glLists[ii] = 0; // Explicitly create a new rendering context instance for this canvas. m_glRC = new wxGLContext( this ); DisplayStatus(); }
void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event ) { if( IsOK( this, _( "Delete selections" ) ) ) { m_skipComponentSelect = true; // Remove all selections to avoid issues when setting the fpids m_compListBox->DeselectAll(); for( unsigned i = 0; i < m_netlist.GetCount(); i++ ) { FPID fpid; m_netlist.GetComponent( i )->SetFPID( fpid ); SetNewPkg( wxEmptyString ); } // Remove all selections after setting the fpids m_compListBox->DeselectAll(); m_skipComponentSelect = false; m_compListBox->SetSelection( 0 ); m_undefinedComponentCnt = m_netlist.GetCount(); } DisplayStatus(); }
void Main_OnDisplay( HWND hWnd ) { TCHAR strAppName[MAX_PATH]={0}; TCHAR strBlock[10]={0}; TCHAR* pEnd=nullptr; TABLEDLG_DATA tblDlgData={0}; // Get the appname, the selected block ID & the selected // language. Create the string block. If the block creation is successful, // bring up the table dialog box. CWindow wnd(hWnd); if (!wnd.GetDlgItemText(IDC_EDIT_APPNAME, strAppName, MAX_PATH)) { DisplayMsg(hWnd, IDS_INVALIDAPPNAME); return; } CComboBox combo(wnd.GetDlgItem(IDC_COMBO_LANGUAGES)); int nSel = combo.GetCurSel(); if( CB_ERR == nSel ) { DisplayMsg(hWnd, IDS_INVALIDLANGUAGE); return; } if (!wnd.GetDlgItemText(IDC_EDIT_BLOCKID, strBlock, _countof(strBlock))) { DisplayMsg(hWnd, IDS_INVALIDBLOCKID); return; } UINT nBlockID = _tcstoul(strBlock, &pEnd, 10); if( *pEnd != 0 ) { DisplayMsg(hWnd, IDS_INVALIDBLOCKID); return; } HSTRBLOCK hStrBlock = GetStringBlock(strAppName, nBlockID, s_langInfo[nSel].wLangID); if( nullptr == hStrBlock ) { DisplayStatus(hWnd, GetStringBlockError()); return; } // Show up the table dialog-box that displays the string block. tblDlgData.strAppName = strAppName; tblDlgData.nBlockID = nBlockID; tblDlgData.wStrID = static_cast<WORD>(s_langInfo[nSel].nStrID); tblDlgData.hStrBlock = hStrBlock; DialogBoxParam(GetAppInstance(), MAKEINTRESOURCE(IDD_DIALOG_TABLE), hWnd, Table_DlgProc, reinterpret_cast<LPARAM>(&tblDlgData)); // Delete the string block. DeleteStringBlock(hStrBlock); }
EDA_3D_CANVAS::EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList ) : wxGLCanvas( parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE ) { m_init = false; m_gllist = 0; // Explicitly create a new rendering context instance for this canvas. m_glRC = new wxGLContext( this ); DisplayStatus(); }
void CVPCB_MAINFRAME::refreshAfterComponentSearch( COMPONENT* component ) { // Tell AuiMgr that objects are changed ! if( m_auimgr.GetManagedWindow() ) // Be sure Aui Manager is initialized // (could be not the case when starting CvPcb m_auimgr.Update(); if( component == NULL ) return; // Preview of the already assigned footprint. // Find the footprint that was already chosen for this component and select it, // but only if the selection is made from the component list or the library list. // If the selection is made from the footprint list, do not change the current // selected footprint. if( FindFocus() == m_compListBox || FindFocus() == m_libListBox ) { wxString module = FROM_UTF8( component->GetFPID().Format().c_str() ); bool found = false; for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ ) { wxString footprintName; wxString msg = m_footprintListBox->OnGetItemText( ii, 0 ); msg.Trim( true ); msg.Trim( false ); footprintName = msg.AfterFirst( wxChar( ' ' ) ); if( module.Cmp( footprintName ) == 0 ) { m_footprintListBox->SetSelection( ii, true ); found = true; break; } } if( !found ) { int ii = m_footprintListBox->GetSelection(); if ( ii >= 0 ) m_footprintListBox->SetSelection( ii, false ); if( GetFootprintViewerFrame() ) { CreateScreenCmp(); } } } SendMessageToEESCHEMA(); DisplayStatus(); }
void EDA_3D_CANVAS::OnMagnify( wxMouseEvent& event ) { double magnification = ( event.GetMagnification() + 1.0f ); GetPrm3DVisu().m_Zoom /= magnification; if( GetPrm3DVisu().m_Zoom <= 0.01 ) GetPrm3DVisu().m_Zoom = 0.01; DisplayStatus(); Refresh( false ); }
INT PageHeap_Execute() { if (!Set && !Unset) { DisplayStatus(); } else { ModifyStatus(); } return 0; }
void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent& event ) { wxSize size( GetClientSize() ); if( event.ShiftDown() ) { if( event.GetWheelRotation() < 0 ) { /* up */ SetView3D( WXK_UP ); } else { /* down */ SetView3D( WXK_DOWN ); } } else if( event.ControlDown() ) { if( event.GetWheelRotation() > 0 ) { /* right */ SetView3D( WXK_RIGHT ); } else { /* left */ SetView3D( WXK_LEFT ); } } else { if( event.GetWheelRotation() > 0 ) { g_Parm_3D_Visu.m_Zoom /= 1.4; if( g_Parm_3D_Visu.m_Zoom <= 0.01 ) g_Parm_3D_Visu.m_Zoom = 0.01; } else g_Parm_3D_Visu.m_Zoom *= 1.4; DisplayStatus(); Refresh( false ); } g_Parm_3D_Visu.m_Beginx = event.GetX(); g_Parm_3D_Visu.m_Beginy = event.GetY(); }
EDA_3D_CANVAS::EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList ) : wxGLCanvas( parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE ) { m_init = false; m_shadow_init = false; // Clear all gl list identifiers: for( int ii = GL_ID_BEGIN; ii < GL_ID_END; ii++ ) m_glLists[ii] = 0; // Explicitly create a new rendering context instance for this canvas. m_glRC = new wxGLContext( this ); DisplayStatus(); }
void CVPCB_MAINFRAME::BuildFOOTPRINTS_LISTBOX() { wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); if( m_footprintListBox == NULL ) { m_footprintListBox = new FOOTPRINTS_LISTBOX( this, ID_CVPCB_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize ); m_footprintListBox->SetFont( wxFont( guiFont.GetPointSize(), wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ) ); } m_footprintListBox->SetFootprints( m_footprints, wxEmptyString, NULL, FOOTPRINTS_LISTBOX::UNFILTERED ); DisplayStatus(); }
/*! * \brief Start background thread for display updates. * * \param name Display device name. * * \return 0 on success or -1 in case of a failure. */ int DisplayInit(char *name) { if ((lcd = fopen(name, "w")) == 0) return -1; if ((sline[0] = malloc(DISPLAY_VCOLUMNS + 1)) == 0 || (sline[1] = malloc(DISPLAY_VCOLUMNS + 1)) == 0 || (mline[0] = malloc(DISPLAY_VCOLUMNS + 1)) == 0 || (mline[1] = malloc(DISPLAY_VCOLUMNS + 1)) == 0) return -1; sline[0][DISPLAY_VCOLUMNS] = 0; sline[1][DISPLAY_VCOLUMNS] = 0; if (NutThreadCreate("displ", Displayer, 0, 512) == 0) return -1; DisplayStatus(DIST_NONE); return 0; }
void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName ) { COMPONENT* component; int componentIndex; if( m_netlist.IsEmpty() ) return; // If no component is selected, select the first one if( m_compListBox->GetFirstSelected() < 0 ) { componentIndex = 0; m_compListBox->SetSelection( componentIndex, true ); } // iterate over the selection while( m_compListBox->GetFirstSelected() != -1 ) { // Get the component for the current iteration componentIndex = m_compListBox->GetFirstSelected(); component = m_netlist.GetComponent( componentIndex ); if( component == NULL ) return; SetNewPkg( aFootprintName, componentIndex ); m_compListBox->SetSelection( componentIndex, false ); } // select the next component, if there is one if( componentIndex < (m_compListBox->GetCount() - 1) ) componentIndex++; m_compListBox->SetSelection( componentIndex, true ); // update the statusbar DisplayStatus(); }
void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event ) { wxSize size( GetClientSize() ); double spin_quat[4]; if( event.Dragging() ) { if( event.LeftIsDown() ) { /* drag in progress, simulate trackball */ trackball( spin_quat, (2.0 * g_Parm_3D_Visu.m_Beginx - size.x) / size.x, (size.y - 2.0 * g_Parm_3D_Visu.m_Beginy) / size.y, ( 2.0 * event.GetX() - size.x) / size.x, ( size.y - 2.0 * event.GetY() ) / size.y ); add_quats( spin_quat, g_Parm_3D_Visu.m_Quat, g_Parm_3D_Visu.m_Quat ); } else if( event.MiddleIsDown() ) { /* middle button drag -> pan */ /* Current zoom and an additional factor are taken into account * for the amount of panning. */ const double PAN_FACTOR = 8.0 * g_Parm_3D_Visu.m_Zoom; m_draw3dOffset.x -= PAN_FACTOR * ( g_Parm_3D_Visu.m_Beginx - event.GetX() ) / size.x; m_draw3dOffset.y -= PAN_FACTOR * (event.GetY() - g_Parm_3D_Visu.m_Beginy) / size.y; } /* orientation has changed, redraw mesh */ DisplayStatus(); Refresh( false ); } g_Parm_3D_Visu.m_Beginx = event.GetX(); g_Parm_3D_Visu.m_Beginy = event.GetY(); }
void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName, int aIndex ) { COMPONENT* component; if( m_netlist.IsEmpty() ) return; component = m_netlist.GetComponent( aIndex ); if( component == NULL ) return; LIB_ID fpid; if( !aFootprintName.IsEmpty() ) { wxCHECK_RET( fpid.Parse( aFootprintName, LIB_ID::ID_PCB ) < 0, wxString::Format( _( "\"%s\" is not a valid LIB_ID." ), aFootprintName ) ); } component->SetFPID( fpid ); // create the new component description wxString description = wxString::Format( CMP_FORMAT, aIndex + 1, GetChars( component->GetReference() ), GetChars( component->GetValue() ), GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) ); // Set the new description and deselect the processed component m_compListBox->SetString( aIndex, description ); // Mark this "session" as modified m_modified = true; // update the statusbar DisplayStatus(); }
//***************************************************************************** // // This is the main application entry function. // //***************************************************************************** int main(void) { uint_fast32_t ui32TxCount; uint_fast32_t ui32RxCount; tRectangle sRect; char pcBuffer[16]; // // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. // ROM_FPULazyStackingEnable(); // // Set the clocking to run from the PLL at 50MHz // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); #ifdef DEBUG // // Configure the UART for debug output. // ConfigureUART(); #endif // // Not configured initially. // g_bUSBConfigured = false; // // Initialize the display driver. // CFAL96x64x16Init(); // // Initialize the graphics context. // GrContextInit(&g_sContext, &g_sCFAL96x64x16); // // Fill the top part of the screen with blue to create the banner. // sRect.i16XMin = 0; sRect.i16YMin = 0; sRect.i16XMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.i16YMax = 9; GrContextForegroundSet(&g_sContext, ClrDarkBlue); GrRectFill(&g_sContext, &sRect); // // Change foreground for white text. // GrContextForegroundSet(&g_sContext, ClrWhite); // // Put the application name in the middle of the banner. // GrContextFontSet(&g_sContext, g_psFontFixed6x8); GrStringDrawCentered(&g_sContext, "usb-dev-bulk", -1, GrContextDpyWidthGet(&g_sContext) / 2, 4, 0); // // Show the various static text elements on the color STN display. // GrStringDraw(&g_sContext, "Tx bytes:", -1, 0, 32, false); GrStringDraw(&g_sContext, "Rx bytes:", -1, 0, 42, false); // // Enable the GPIO peripheral used for USB, and configure the USB // pins. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL); ROM_GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); ROM_GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7); // // Enable the system tick. // ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKS_PER_SECOND); ROM_SysTickIntEnable(); ROM_SysTickEnable(); // // Show the application name on the display and UART output. // DEBUG_PRINT("\nTiva C Series USB bulk device example\n"); DEBUG_PRINT("---------------------------------\n\n"); // // Tell the user what we are up to. // DisplayStatus(&g_sContext, "Configuring USB"); // // Initialize the transmit and receive buffers. // USBBufferInit(&g_sTxBuffer); USBBufferInit(&g_sRxBuffer); // // Pass our device information to the USB library and place the device // on the bus. // USBDBulkInit(0, &g_sBulkDevice); // // Wait for initial configuration to complete. // DisplayStatus(&g_sContext, "Waiting for host"); // // Clear our local byte counters. // ui32RxCount = 0; ui32TxCount = 0; // // Main application loop. // while(1) { // // Have we been asked to update the status display? // if(g_ui32Flags & COMMAND_STATUS_UPDATE) { // // Clear the command flag // g_ui32Flags &= ~COMMAND_STATUS_UPDATE; DisplayStatus(&g_sContext, g_pcStatus); } // // Has there been any transmit traffic since we last checked? // if(ui32TxCount != g_ui32TxCount) { // // Take a snapshot of the latest transmit count. // ui32TxCount = g_ui32TxCount; // // Update the display of bytes transmitted by the UART. // usnprintf(pcBuffer, 16, " %d ", ui32TxCount); GrStringDraw(&g_sContext, pcBuffer, -1, 48, 32, true); } // // Has there been any receive traffic since we last checked? // if(ui32RxCount != g_ui32RxCount) { // // Take a snapshot of the latest receive count. // ui32RxCount = g_ui32RxCount; // // Update the display of bytes received by the UART. // usnprintf(pcBuffer, 16, " %d ", ui32RxCount); GrStringDraw(&g_sContext, pcBuffer, -1, 48, 42, true); } } }
void PlayLoop (void) { id0_char_t shot_color[3] = {4,9,14}; id0_int_t allgems[5]={GEM_DELAY_TIME, // used for Q & D comparison GEM_DELAY_TIME, // for having all gems... GEM_DELAY_TIME, // the "allgems" declaration MUST GEM_DELAY_TIME, // match the "gems" declaration in GEM_DELAY_TIME // the gametype structure! }; // id0_int_t originx=0; // id0_int_t i=100; id0_signed_long_t dx,dy/*,radius*/,psin,pcos,newx,newy; //id0_int_t give; id0_short_t objnum; id0_signed_long_t ox,oy,xl,xh,yl,yh,px,py,norm_dx,norm_dy; id0_short_t o_radius; void (*think)(struct objstruct *); // REFKEEN: C++ patch ingame = true; SD_SetTimeCount(0); playstate = (exittype)0; //playstate = TimeCount = 0; gamestate.shotpower = handheight = 0; pointcount = pointsleft = 0; status_flag = S_NONE; #if 0 // setup sky/ground colors and effects (based on level) // switch (gamestate.mapon) { case 255: if (!(BGFLAGS & BGF_NIGHT)) { InitBgChange(3*60,sky_daytonight,-1,NULL,BGF_NIGHT); groundcolor = &gnd_colors[0]; } else { skycolor = &sky_colors[0]; groundcolor = &gnd_colors[0]; } break; default: skycolor = &sky_colors[gamestate.mapon]; groundcolor = &gnd_colors[gamestate.mapon]; skytimer = groundtimer = -1; break; } #endif BGFLAGS |= BGF_NOT_LIGHTNING; skytimer = groundtimer = -1; debug_gnd = *groundcolor; debug_sky = *skycolor; RedrawStatusWindow(); ThreeDRefresh(); if (screenfaded) VW_FadeIn(); #ifndef PROFILE fizzlein = true; // fizzle fade in the first refresh #endif /*TimeCount = */lasttimecount = lastnuke = 0; SD_SetTimeCount(0); PollControls (); // center mouse // StartMusic (); do { #ifndef PROFILE PollControls(); #else control.xaxis = 1; //if (++TimeCount == 300) // return; SD_AddToTimeCount(1); if (SD_GetTimeCount() == 300) return; #endif DisplayStatus(&status_flag); objnum=0; for (obj = player;obj;obj = obj->next) { if ((obj->active >= yes) && (!(FreezeTime && (obj!=player)))) { if (obj->ticcount) { obj->ticcount-=realtics; while ( obj->ticcount <= 0) { think = obj->state->thinkptr; if (think) { statetype *oldstate=obj->state; think (obj); if (!obj->state) { RemoveObj (obj); goto nextactor; } if (obj->state != oldstate) break; } obj->state = obj->state->next; if (!obj->state) { RemoveObj (obj); goto nextactor; } if (!obj->state->tictime) { obj->ticcount = 0; goto nextactor; } if (obj->state->tictime>0) obj->ticcount += obj->state->tictime; } } think = obj->state->thinkptr; if (think) { think (obj); if (!obj->state) RemoveObj (obj); } nextactor:; } // keep a list of objects around the player for radar updates // if (obj == player) { px = player->x; py = player->y; psin = sintable[player->angle]; pcos = costable[player->angle]; xl = px-((id0_long_t)RADAR_WIDTH<<TILESHIFT)/2; xh = px+((id0_long_t)RADAR_WIDTH<<TILESHIFT)/2-1; yl = py-((id0_long_t)RADAR_HEIGHT<<TILESHIFT)/2; yh = py+((id0_long_t)RADAR_HEIGHT<<TILESHIFT)/2; } if (objnum > MAX_RADAR_BLIPS-2) objnum = MAX_RADAR_BLIPS-2; ox = obj->x; oy = obj->y; if ((ox >= xl) && (ox <= xh) && (oy >= yl) && (oy <= yh)) { norm_dx = (dx = px-ox)>>TILESHIFT; norm_dy = (dy = oy-py)>>TILESHIFT; id0_int_t IntSqrt(id0_long_t va); o_radius = IntSqrt((norm_dx * norm_dx) + (norm_dy * norm_dy)); if (o_radius < RADAR_RADIUS) { newx = FixedByFrac(dy,pcos)-FixedByFrac(dx,psin); newy = FixedByFrac(dy,psin)+FixedByFrac(dx,pcos); RadarXY[objnum][0]=newx>>TILESHIFT; RadarXY[objnum][1]=newy>>TILESHIFT; // Define color to use for this object... // switch (obj->obclass) { // NO GEM NEEDED // // THE WIZARD! (YOU) // case playerobj: RadarXY[objnum++][2]=15; break; // WIZARD'S SHOTS // case pshotobj: case bigpshotobj: RadarXY[objnum++][2]=shot_color[screenpage]; break; // BATS (DK GRAY) // case batobj: if (obj->active == always) RadarXY[objnum++][2]=8; break; // RABBITS (LT GRAY) // case bunnyobj: if (obj->active == always) RadarXY[objnum++][2]=7; break; // RED GEM // // EYE, RED DEMON (DK RED) // case eyeobj: case reddemonobj: if (gamestate.gems[B_RGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=4; break; // RED MAGE (LT RED) // case mageobj: if (gamestate.gems[B_RGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=12; break; // BLUE GEM // // SUCCUBUS (LT BLUE) // case succubusobj: if (gamestate.gems[B_BGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=9; break; // WATER DRAGON (DK BLUE) // case wetobj: if (gamestate.gems[B_GGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=1; break; // GREEN GEM // // GREEN TROLL (LT GREEN) // case fatdemonobj: if (gamestate.gems[B_GGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=10; break; // GODESS (DK GREEN) // case godessobj: if (gamestate.gems[B_GGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=2; break; // YELLOW GEM // // ANT (BROWN) // case antobj: case treeobj: if (gamestate.gems[B_YGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=6; break; // SKELETON (YELLOW) // case skeletonobj: if (gamestate.gems[B_YGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=14; break; // PURPLE GEM // // ZOMBIE // case zombieobj: if (gamestate.gems[B_PGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=13; break; // ALL GEMS NEEDED // // NEMESIS // case grelmobj: if (!memcmp(gamestate.gems,allgems,sizeof(gamestate.gems))) if (obj->active == always) RadarXY[objnum++][2]=15; break; } } } }
//***************************************************************************** // // This is the main application entry function. // //***************************************************************************** int main(void) { uint32_t ui32TxCount; uint32_t ui32RxCount; tRectangle sRect; char pcBuffer[16]; uint32_t ui32Fullness; // // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. // ROM_FPULazyStackingEnable(); // // Set the clocking to run from the PLL at 50MHz // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Configure the required pins for USB operation. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); ROM_GPIOPinConfigure(GPIO_PG4_USB0EPEN); ROM_GPIOPinTypeUSBDigital(GPIO_PORTG_BASE, GPIO_PIN_4); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL); ROM_GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7); ROM_GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Erratum workaround for silicon revision A1. VBUS must have pull-down. // if(CLASS_IS_BLIZZARD && REVISION_IS_A1) { HWREG(GPIO_PORTB_BASE + GPIO_O_PDR) |= GPIO_PIN_1; } // // Not configured initially. // g_bUSBConfigured = false; // // Initialize the display driver. // CFAL96x64x16Init(); // // Initialize the graphics context. // GrContextInit(&g_sContext, &g_sCFAL96x64x16); // // Fill the top 15 rows of the screen with blue to create the banner. // sRect.i16XMin = 0; sRect.i16YMin = 0; sRect.i16XMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.i16YMax = 9; GrContextForegroundSet(&g_sContext, ClrDarkBlue); GrRectFill(&g_sContext, &sRect); // // Put a white box around the banner. // GrContextForegroundSet(&g_sContext, ClrWhite); GrRectDraw(&g_sContext, &sRect); // // Put the application name in the middle of the banner. // GrContextFontSet(&g_sContext, g_psFontFixed6x8); GrStringDrawCentered(&g_sContext, "usb-dev-serial", -1, GrContextDpyWidthGet(&g_sContext) / 2, 4, 0); // // Show the various static text elements on the color STN display. // GrStringDraw(&g_sContext, "Tx #",-1, 0, 12, false); GrStringDraw(&g_sContext, "Tx buf", -1, 0, 22, false); GrStringDraw(&g_sContext, "Rx #", -1, 0, 32, false); GrStringDraw(&g_sContext, "Rx buf", -1, 0, 42, false); DrawBufferMeter(&g_sContext, 40, 22); DrawBufferMeter(&g_sContext, 40, 42); // // Enable the UART that we will be redirecting. // ROM_SysCtlPeripheralEnable(USB_UART_PERIPH); // // Enable and configure the UART RX and TX pins // ROM_SysCtlPeripheralEnable(TX_GPIO_PERIPH); ROM_SysCtlPeripheralEnable(RX_GPIO_PERIPH); ROM_GPIOPinTypeUART(TX_GPIO_BASE, TX_GPIO_PIN); ROM_GPIOPinTypeUART(RX_GPIO_BASE, RX_GPIO_PIN); // // TODO: Add code to configure handshake GPIOs if required. // // // Set the default UART configuration. // ROM_UARTConfigSetExpClk(USB_UART_BASE, ROM_SysCtlClockGet(), DEFAULT_BIT_RATE, DEFAULT_UART_CONFIG); ROM_UARTFIFOLevelSet(USB_UART_BASE, UART_FIFO_TX4_8, UART_FIFO_RX4_8); // // Configure and enable UART interrupts. // ROM_UARTIntClear(USB_UART_BASE, ROM_UARTIntStatus(USB_UART_BASE, false)); ROM_UARTIntEnable(USB_UART_BASE, (UART_INT_OE | UART_INT_BE | UART_INT_PE | UART_INT_FE | UART_INT_RT | UART_INT_TX | UART_INT_RX)); // // Enable the system tick. // ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKS_PER_SECOND); ROM_SysTickIntEnable(); ROM_SysTickEnable(); // // Tell the user what we are up to. // DisplayStatus(&g_sContext, " Configuring... "); // // Initialize the transmit and receive buffers. // USBBufferInit(&g_sTxBuffer); USBBufferInit(&g_sRxBuffer); // // Set the USB stack mode to Device mode with VBUS monitoring. // USBStackModeSet(0, eUSBModeDevice, 0); // // Pass our device information to the USB library and place the device // on the bus. // USBDCDCInit(0, &g_sCDCDevice); // // Wait for initial configuration to complete. // DisplayStatus(&g_sContext, "Waiting for host"); // // Clear our local byte counters. // ui32RxCount = 0; ui32TxCount = 0; // // Enable interrupts now that the application is ready to start. // ROM_IntEnable(USB_UART_INT); // // Main application loop. // while(1) { // // Have we been asked to update the status display? // if(g_ui32Flags & COMMAND_STATUS_UPDATE) { // // Clear the command flag // ROM_IntMasterDisable(); g_ui32Flags &= ~COMMAND_STATUS_UPDATE; ROM_IntMasterEnable(); DisplayStatus(&g_sContext, g_pcStatus); } // // Has there been any transmit traffic since we last checked? // if(ui32TxCount != g_ui32UARTTxCount) { // // Take a snapshot of the latest transmit count. // ui32TxCount = g_ui32UARTTxCount; // // Update the display of bytes transmitted by the UART. // usnprintf(pcBuffer, 16, "%d ", ui32TxCount); GrStringDraw(&g_sContext, pcBuffer, -1, 40, 12, true); // // Update the RX buffer fullness. Remember that the buffers are // named relative to the USB whereas the status display is from // the UART's perspective. The USB's receive buffer is the UART's // transmit buffer. // ui32Fullness = ((USBBufferDataAvailable(&g_sRxBuffer) * 100) / UART_BUFFER_SIZE); UpdateBufferMeter(&g_sContext, ui32Fullness, 40, 22); } // // Has there been any receive traffic since we last checked? // if(ui32RxCount != g_ui32UARTRxCount) { // // Take a snapshot of the latest receive count. // ui32RxCount = g_ui32UARTRxCount; // // Update the display of bytes received by the UART. // usnprintf(pcBuffer, 16, "%d ", ui32RxCount); GrStringDraw(&g_sContext, pcBuffer, -1, 40, 32, true); // // Update the TX buffer fullness. Remember that the buffers are // named relative to the USB whereas the status display is from // the UART's perspective. The USB's transmit buffer is the UART's // receive buffer. // ui32Fullness = ((USBBufferDataAvailable(&g_sTxBuffer) * 100) / UART_BUFFER_SIZE); UpdateBufferMeter(&g_sContext, ui32Fullness, 40, 42); } } }
// === Public functions HRESULT TDXVADecoderVC1::DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop) { HRESULT hr; int nSurfaceIndex; CComPtr<IMediaSample> pSampleToDeliver; int nFieldType, nSliceType; UINT nFrameSize, nSize_Result; m_pCodec->libavcodec->FFVC1UpdatePictureParam(&m_PictureParams, m_pCodec->avctx, &nFieldType, &nSliceType, pDataIn, nSize, &nFrameSize, FALSE, &m_bFrame_repeat_pict); if (m_pCodec->libavcodec->FFIsSkipped(m_pCodec->avctx)) { return S_OK; } // Wait I frame after a flush if (m_bFlushed && ! m_PictureParams.bPicIntra) { return S_FALSE; } hr = GetFreeSurfaceIndex(nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop); if (FAILED(hr)) { ASSERT(hr == VFW_E_NOT_COMMITTED); // Normal when stop playing return hr; } CHECK_HR(BeginFrame(nSurfaceIndex, pSampleToDeliver)); DPRINTF(_l("TDXVADecoderVC1::DecodeFrame - PictureType = %s, rtStart = %I64d Surf=%d\n"), m_pCodec->libavcodec->GetFFMpegPictureType(nSliceType), rtStart, nSurfaceIndex); m_PictureParams.wDecodedPictureIndex = nSurfaceIndex; m_PictureParams.wDeblockedPictureIndex = m_PictureParams.wDecodedPictureIndex; // Manage reference picture list if (!m_PictureParams.bPicBackwardPrediction) { if (m_wRefPictureIndex[0] != NO_REF_FRAME) { RemoveRefFrame(m_wRefPictureIndex[0]); } m_wRefPictureIndex[0] = m_wRefPictureIndex[1]; m_wRefPictureIndex[1] = nSurfaceIndex; } m_PictureParams.wForwardRefPictureIndex = (m_PictureParams.bPicIntra == 0) ? m_wRefPictureIndex[0] : NO_REF_FRAME; m_PictureParams.wBackwardRefPictureIndex = (m_PictureParams.bPicBackwardPrediction == 1) ? m_wRefPictureIndex[1] : NO_REF_FRAME; m_PictureParams.bPic4MVallowed = (m_PictureParams.wBackwardRefPictureIndex == NO_REF_FRAME && m_PictureParams.bPicStructure == 3) ? 1 : 0; m_PictureParams.bPicDeblockConfined |= (m_PictureParams.wBackwardRefPictureIndex == NO_REF_FRAME) ? 0x04 : 0; m_PictureParams.bPicScanMethod++; // Use for status reporting sections 3.8.1 and 3.8.2 DPRINTF(_l("TDXVADecoderVC1::DecodeFrame - Decode frame %i\n"), m_PictureParams.bPicScanMethod); // Send picture params to accelerator CHECK_HR(AddExecuteBuffer(DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams)); // Send bitstream to accelerator CHECK_HR(AddExecuteBuffer(DXVA2_BitStreamDateBufferType, nFrameSize ? nFrameSize : nSize, pDataIn, &nSize_Result)); m_SliceInfo.wQuantizerScaleCode = 1; // TODO : 1->31 ??? m_SliceInfo.dwSliceBitsInBuffer = nSize_Result * 8; CHECK_HR(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(m_SliceInfo), &m_SliceInfo)); // Decode frame CHECK_HR(Execute()); CHECK_HR(EndFrame(nSurfaceIndex)); // *************** if (nFrameSize) { // Decoding Second Field m_pCodec->libavcodec->FFVC1UpdatePictureParam(&m_PictureParams, m_pCodec->avctx, NULL, NULL, pDataIn, nSize, NULL, TRUE, &m_bFrame_repeat_pict); CHECK_HR(BeginFrame(nSurfaceIndex, pSampleToDeliver)); DPRINTF(_l("TDXVADecoderVC1::DecodeFrame - PictureType = %s\n"), m_pCodec->libavcodec->GetFFMpegPictureType(nSliceType)); CHECK_HR(AddExecuteBuffer(DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams)); // Send bitstream to accelerator CHECK_HR(AddExecuteBuffer(DXVA2_BitStreamDateBufferType, nSize - nFrameSize, pDataIn + nFrameSize, &nSize_Result)); m_SliceInfo.wQuantizerScaleCode = 1; // TODO : 1->31 ??? m_SliceInfo.dwSliceBitsInBuffer = nSize_Result * 8; CHECK_HR(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(m_SliceInfo), &m_SliceInfo)); // Decode frame CHECK_HR(Execute()); CHECK_HR(EndFrame(nSurfaceIndex)); } // *************** #ifdef _DEBUG DisplayStatus(); #endif // Re-order B frames if (m_pCodec->isReorderBFrame()) { if (m_PictureParams.bPicBackwardPrediction == 1) { SwapRT(rtStart, m_rtStartDelayed); SwapRT(rtStop, m_rtStopDelayed); } else { // Save I or P reference time (swap later) if (!m_bFlushed) { if (m_nDelayedSurfaceIndex != -1) { UpdateStore(m_nDelayedSurfaceIndex, m_rtStartDelayed, m_rtStopDelayed); } m_rtStartDelayed = m_rtStopDelayed = _I64_MAX; SwapRT(rtStart, m_rtStartDelayed); SwapRT(rtStop, m_rtStopDelayed); m_nDelayedSurfaceIndex = nSurfaceIndex; } } } AddToStore(nSurfaceIndex, pSampleToDeliver, (m_PictureParams.bPicBackwardPrediction != 1), rtStart, rtStop, false, (FF_FIELD_TYPE)nFieldType, (FF_SLICE_TYPE)nSliceType, 0); m_bFlushed = false; return DisplayNextFrame(); }
void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) { if( m_skipComponentSelect ) return; wxString libraryName; COMPONENT* component = NULL; int filter = FOOTPRINTS_LISTBOX::UNFILTERED; if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) ) filter |= FOOTPRINTS_LISTBOX::BY_COMPONENT; if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST ) ) filter |= FOOTPRINTS_LISTBOX::BY_PIN_COUNT; if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST ) ) filter |= FOOTPRINTS_LISTBOX::BY_LIBRARY; component = GetSelectedComponent(); libraryName = m_libListBox->GetSelectedLibrary(); m_footprintListBox->SetFootprints( m_footprints, libraryName, component, filter ); // Tell AuiMgr that objects are changed ! if( m_auimgr.GetManagedWindow() ) // Be sure Aui Manager is initialized // (could be not the case when starting CvPcb m_auimgr.Update(); if( component == NULL ) return; // Preview of the already assigned footprint. // Find the footprint that was already chosen for this component and select it, // but only if the selection is made from the component list or the library list. // If the selection is made from the footprint list, do not change the current // selected footprint. if( FindFocus() == m_compListBox || FindFocus() == m_libListBox ) { wxString module = FROM_UTF8( component->GetFPID().Format().c_str() ); bool found = false; for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ ) { wxString footprintName; wxString msg = m_footprintListBox->OnGetItemText( ii, 0 ); msg.Trim( true ); msg.Trim( false ); footprintName = msg.AfterFirst( wxChar( ' ' ) ); if( module.Cmp( footprintName ) == 0 ) { m_footprintListBox->SetSelection( ii, true ); found = true; break; } } if( !found ) { int ii = m_footprintListBox->GetSelection(); if ( ii >= 0 ) m_footprintListBox->SetSelection( ii, false ); if( GetFpViewerFrame() ) { CreateScreenCmp(); } } } SendMessageToEESCHEMA(); DisplayStatus(); }
HRESULT CDXVADecoderH264::DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop) { HRESULT hr = S_FALSE; UINT nSlices = 0; int nSurfaceIndex = -1; int nFieldType = -1; int nSliceType = -1; int nFramePOC = INT_MIN; int nOutPOC = INT_MIN; REFERENCE_TIME rtOutStart = _I64_MIN; CH264Nalu Nalu; UINT nNalOffset = 0; CComPtr<IMediaSample> pSampleToDeliver; CComQIPtr<IMPCDXVA2Sample> pDXVA2Sample; int slice_step = 1; if (FFH264DecodeBuffer(m_pFilter->GetAVCtx(), pDataIn, nSize, &nFramePOC, &nOutPOC, &rtOutStart) == -1) { return S_FALSE; } while (!nSlices && slice_step <= 2) { Nalu.SetBuffer(pDataIn, nSize, slice_step == 1 ? m_nNALLength : 0); while (Nalu.ReadNext()) { switch (Nalu.GetType()) { case NALU_TYPE_SLICE: case NALU_TYPE_IDR: if (m_bUseLongSlice) { m_pSliceLong[nSlices].BSNALunitDataLocation = nNalOffset; m_pSliceLong[nSlices].SliceBytesInBuffer = (UINT)Nalu.GetDataLength() + 3; //.GetRoundedDataLength(); m_pSliceLong[nSlices].slice_id = nSlices; FF264UpdateRefFrameSliceLong(&m_DXVAPicParams, &m_pSliceLong[nSlices], m_pFilter->GetAVCtx()); if (nSlices > 0) { m_pSliceLong[nSlices - 1].NumMbsForSlice = m_pSliceLong[nSlices].NumMbsForSlice = m_pSliceLong[nSlices].first_mb_in_slice - m_pSliceLong[nSlices - 1].first_mb_in_slice; } } nSlices++; nNalOffset += (UINT)(Nalu.GetDataLength() + 3); if (nSlices > MAX_SLICES) { break; } break; } } slice_step++; } if (!nSlices) { return S_FALSE; } m_nMaxWaiting = min(max(m_DXVAPicParams.num_ref_frames, 3), 8); // If parsing fail (probably no PPS/SPS), continue anyway it may arrived later (happen on truncated streams) if (FAILED(FFH264BuildPicParams(&m_DXVAPicParams, &m_DXVAScalingMatrix, &nFieldType, &nSliceType, m_pFilter->GetAVCtx(), m_pFilter->GetPCIVendor()))) { return S_FALSE; } TRACE_H264("CDXVADecoderH264::DecodeFrame() : nFramePOC = %11d, nOutPOC = %11d[%11d], [%d - %d], rtOutStart = [%20I64d]\n", nFramePOC, nOutPOC, m_nOutPOC, m_DXVAPicParams.field_pic_flag, m_DXVAPicParams.RefPicFlag, rtOutStart); // Wait I frame after a flush if (m_bFlushed && !m_DXVAPicParams.IntraPicFlag) { TRACE_H264("CDXVADecoderH264::DecodeFrame() : Flush - wait I frame\n"); m_nBrokenFramesFlag = 0; m_nBrokenFramesFlag_POC = 0; m_nfield_pic_flag = m_DXVAPicParams.field_pic_flag; m_nRefPicFlag = m_DXVAPicParams.RefPicFlag; m_nPrevOutPOC = INT_MIN; return S_FALSE; } /* Disabled, because that causes serious problems. // Some magic code for detecting the incorrect decoding of interlaced frames ... // TODO : necessary to make it better, and preferably on the side of ffmpeg ... if (m_nfield_pic_flag && m_nfield_pic_flag == m_DXVAPicParams.field_pic_flag && m_nRefPicFlag == m_DXVAPicParams.RefPicFlag) { if (m_nPrevOutPOC == m_nOutPOC && m_nOutPOC == INT_MIN) { m_nBrokenFramesFlag_POC++; } m_nBrokenFramesFlag++; } else { m_nBrokenFramesFlag = 0; m_nBrokenFramesFlag_POC = 0; } m_nfield_pic_flag = m_DXVAPicParams.field_pic_flag; m_nRefPicFlag = m_DXVAPicParams.RefPicFlag; m_nPrevOutPOC = m_nOutPOC; if (m_nBrokenFramesFlag > 4) { m_nBrokenFramesFlag = 0; if (m_nBrokenFramesFlag_POC > 1) { TRACE_H264("CDXVADecoderH264::DecodeFrame() : Detected broken frames ... flush data\n"); m_nBrokenFramesFlag_POC = 0; Flush(); return S_FALSE; } } // */ CHECK_HR_TRACE(GetFreeSurfaceIndex(nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop)); FFH264SetCurrentPicture(nSurfaceIndex, &m_DXVAPicParams, m_pFilter->GetAVCtx()); CHECK_HR_TRACE(BeginFrame(nSurfaceIndex, pSampleToDeliver)); m_DXVAPicParams.StatusReportFeedbackNumber++; // Send picture parameters CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_PictureParametersBufferType, sizeof(m_DXVAPicParams), &m_DXVAPicParams)); CHECK_HR_TRACE(Execute()); // Add bitstream, slice control and quantization matrix CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_BitStreamDateBufferType, nSize, pDataIn, &nSize)); if (m_bUseLongSlice) { CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(DXVA_Slice_H264_Long)*nSlices, m_pSliceLong)); } else { CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(DXVA_Slice_H264_Short)*nSlices, m_pSliceShort)); } CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_InverseQuantizationMatrixBufferType, sizeof(DXVA_Qmatrix_H264), (void*)&m_DXVAScalingMatrix)); // Decode bitstream CHECK_HR_TRACE(Execute()); CHECK_HR_TRACE(EndFrame(nSurfaceIndex)); #if defined(_DEBUG) && 0 DisplayStatus(); #endif bool bAdded = AddToStore(nSurfaceIndex, pSampleToDeliver, m_DXVAPicParams.RefPicFlag, rtStart, rtStop, m_DXVAPicParams.field_pic_flag, (FF_FIELD_TYPE)nFieldType, (FF_SLICE_TYPE)nSliceType, nFramePOC); FFH264UpdateRefFramesList(&m_DXVAPicParams, m_pFilter->GetAVCtx()); ClearUnusedRefFrames(); if (bAdded) { hr = DisplayNextFrame(); } if (nOutPOC != INT_MIN) { m_nOutPOC = nOutPOC; m_rtOutStart = rtOutStart; } m_bFlushed = false; return hr; }
//***************************************************************************** // // This is the main application entry function. // //***************************************************************************** int main(void) { uint32_t ui32TxCount, ui32RxCount, ui32Fullness, ui32SysClock, ui32PLLRate; tRectangle sRect; char pcBuffer[16]; #ifdef USE_ULPI uint32_t ui32Setting; #endif // // Set the system clock to run at 120MHz from the PLL. // ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); // // Configure the device pins. // PinoutSet(); #ifdef USE_ULPI // // Switch the USB ULPI Pins over. // USBULPIPinoutSet(); // // Enable USB ULPI with high speed support. // ui32Setting = USBLIB_FEATURE_ULPI_HS; USBOTGFeatureSet(0, USBLIB_FEATURE_USBULPI, &ui32Setting); // // Setting the PLL frequency to zero tells the USB library to use the // external USB clock. // ui32PLLRate = 0; #else // // Save the PLL rate used by this application. // ui32PLLRate = 480000000; #endif // // Enable the system tick. // ROM_SysTickPeriodSet(ui32SysClock / TICKS_PER_SECOND); ROM_SysTickIntEnable(); ROM_SysTickEnable(); // // Not configured initially. // g_ui32Flags = 0; // // Initialize the display driver. // Kentec320x240x16_SSD2119Init(ui32SysClock); // // Initialize the graphics context. // GrContextInit(&g_sContext, &g_sKentec320x240x16_SSD2119); // // Draw the application frame. // FrameDraw(&g_sContext, "usb-dev-serial"); // // Fill the top 15 rows of the screen with blue to create the banner. // sRect.i16XMin = 0; sRect.i16YMin = 0; sRect.i16XMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.i16YMax = 23; GrContextForegroundSet(&g_sContext, ClrDarkBlue); GrRectFill(&g_sContext, &sRect); // // Put a white box around the banner. // GrContextForegroundSet(&g_sContext, ClrWhite); GrRectDraw(&g_sContext, &sRect); // // Show the various static text elements on the color STN display. // GrContextFontSet(&g_sContext, TEXT_FONT); GrStringDraw(&g_sContext, "Tx bytes:", -1, 8, 80, false); GrStringDraw(&g_sContext, "Tx buffer:", -1, 8, 105, false); GrStringDraw(&g_sContext, "Rx bytes:", -1, 8, 160, false); GrStringDraw(&g_sContext, "Rx buffer:", -1, 8, 185, false); DrawBufferMeter(&g_sContext, 150, 105); DrawBufferMeter(&g_sContext, 150, 185); // // Enable the UART that we will be redirecting. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); // // Change the UART clock to the 16 MHz PIOSC. // UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC); // // Set the default UART configuration. // ROM_UARTConfigSetExpClk(UART0_BASE, UART_CLOCK, DEFAULT_BIT_RATE, DEFAULT_UART_CONFIG); ROM_UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX4_8, UART_FIFO_RX4_8); // // Configure and enable UART interrupts. // ROM_UARTIntClear(UART0_BASE, ROM_UARTIntStatus(UART0_BASE, false)); ROM_UARTIntEnable(UART0_BASE, (UART_INT_OE | UART_INT_BE | UART_INT_PE | UART_INT_FE | UART_INT_RT | UART_INT_TX | UART_INT_RX)); // // Tell the user what we are up to. // DisplayStatus(&g_sContext, " Configuring USB... "); // // Initialize the transmit and receive buffers. // USBBufferInit(&g_sTxBuffer); USBBufferInit(&g_sRxBuffer); // // Set the USB stack mode to Device mode with VBUS monitoring. // USBStackModeSet(0, eUSBModeDevice, 0); // // Tell the USB library the CPU clock and the PLL frequency. This is a // new requirement for TM4C129 devices. // USBDCDFeatureSet(0, USBLIB_FEATURE_CPUCLK, &ui32SysClock); USBDCDFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate); // // Pass our device information to the USB library and place the device // on the bus. // USBDCDCInit(0, (tUSBDCDCDevice *)&g_sCDCDevice); // // Wait for initial configuration to complete. // DisplayStatus(&g_sContext, " Waiting for host... "); // // Clear our local byte counters. // ui32RxCount = 0; ui32TxCount = 0; g_ui32UARTTxCount = 0; g_ui32UARTRxCount = 0; #ifdef DEBUG g_ui32UARTRxErrors = 0; #endif // // Enable interrupts now that the application is ready to start. // ROM_IntEnable(INT_UART0); // // Main application loop. // while(1) { // // Have we been asked to update the status display? // if(HWREGBITW(&g_ui32Flags, FLAG_STATUS_UPDATE)) { // // Clear the command flag // HWREGBITW(&g_ui32Flags, FLAG_STATUS_UPDATE) = 0; DisplayStatus(&g_sContext, g_pcStatus); } // // Has there been any transmit traffic since we last checked? // if(ui32TxCount != g_ui32UARTTxCount) { // // Take a snapshot of the latest transmit count. // ui32TxCount = g_ui32UARTTxCount; // // Update the display of bytes transmitted by the UART. // usnprintf(pcBuffer, 16, "%d ", ui32TxCount); GrStringDraw(&g_sContext, pcBuffer, -1, 150, 80, true); // // Update the RX buffer fullness. Remember that the buffers are // named relative to the USB whereas the status display is from // the UART's perspective. The USB's receive buffer is the UART's // transmit buffer. // ui32Fullness = ((USBBufferDataAvailable(&g_sRxBuffer) * 100) / UART_BUFFER_SIZE); UpdateBufferMeter(&g_sContext, ui32Fullness, 150, 105); } // // Has there been any receive traffic since we last checked? // if(ui32RxCount != g_ui32UARTRxCount) { // // Take a snapshot of the latest receive count. // ui32RxCount = g_ui32UARTRxCount; // // Update the display of bytes received by the UART. // usnprintf(pcBuffer, 16, "%d ", ui32RxCount); GrStringDraw(&g_sContext, pcBuffer, -1, 150, 160, true); // // Update the TX buffer fullness. Remember that the buffers are // named relative to the USB whereas the status display is from // the UART's perspective. The USB's transmit buffer is the UART's // receive buffer. // ui32Fullness = ((USBBufferDataAvailable(&g_sTxBuffer) * 100) / UART_BUFFER_SIZE); UpdateBufferMeter(&g_sContext, ui32Fullness, 150, 185); } } }
//***************************************************************************** // // This is the main application entry function. // //***************************************************************************** int main(void) { unsigned int ulTxCount; unsigned int ulRxCount; tRectangle sRect; char pcBuffer[16]; unsigned int ulFullness; unsigned int intFlags = 0; unsigned char Intstatus; unsigned int i; unsigned char *src, *dest; MMUConfigAndEnable(); // // Not configured initially. // g_bUSBConfigured = false; // //configures arm interrupt controller to generate raster interrupt // USBInterruptEnable(); // //LCD Back light setup // LCDBackLightEnable(); // //UPD Pin setup // UPDNPinControl(); // //Delay timer setup // DelayTimerSetup(); // //Configures raster to display image // SetUpLCD(); RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int)(g_pucBuffer+PALETTE_OFFSET), (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET, FRAME_BUFFER_0); RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int)(g_pucBuffer+PALETTE_OFFSET), (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET, FRAME_BUFFER_1); src = (unsigned char *) palette_32b; dest = (unsigned char *) (g_pucBuffer+PALETTE_OFFSET); // Copy palette info into buffer for( i = PALETTE_OFFSET; i < (PALETTE_SIZE+PALETTE_OFFSET); i++) { *dest++ = *src++; } GrOffScreen24BPPInit(&g_s35_480x272x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT); // Initialize a drawing context. GrContextInit(&g_sContext, &g_s35_480x272x24Display); /* enable End of frame interrupt */ RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS); /* enable raster */ RasterEnable(SOC_LCDC_0_REGS); // // Fill the top 24 rows of the screen with blue to create the banner. // sRect.sXMin = 0; sRect.sYMin = 0; sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.sYMax = 23; GrContextForegroundSet(&g_sContext, ClrDarkBlue); GrRectFill(&g_sContext, &sRect); // // Put a white box around the banner. // GrContextForegroundSet(&g_sContext, ClrWhite); GrRectDraw(&g_sContext, &sRect); // // Put the application name in the middle of the banner. // GrContextFontSet(&g_sContext, &g_sFontCm20); GrStringDrawCentered(&g_sContext, "usb-dev-serial", -1, GrContextDpyWidthGet(&g_sContext) / 2, 10, 0); // // Show the various static text elements on the color STN display. // GrContextFontSet(&g_sContext, TEXT_FONT); GrStringDraw(&g_sContext, "Tx bytes:", -1, 8, 80, false); GrStringDraw(&g_sContext, "Tx buffer:", -1, 8, 105, false); GrStringDraw(&g_sContext, "Rx bytes:", -1, 8, 160, false); GrStringDraw(&g_sContext, "Rx buffer:", -1, 8, 185, false); DrawBufferMeter(&g_sContext, 150, 105); DrawBufferMeter(&g_sContext, 150, 185); // // Tell the user what we are up to. // DisplayStatus(&g_sContext, " Configuring USB... "); // //Initialize the Rx and TX Buffers // USBBufferInit((tUSBBuffer *)&g_sTxBuffer); USBBufferInit((tUSBBuffer *)&g_sRxBuffer); // // Pass our device information to the USB library and place the device // on the bus. // USBDCDCInit(0, (tUSBDCDCDevice *)&g_sCDCDevice); // // Wait for initial configuration to complete. // DisplayStatus(&g_sContext, " Waiting for host... "); // // Clear our local byte counters. // ulRxCount = 0; ulTxCount = 0; /* Configuring the system clocks for UART0 instance. */ UART0ModuleClkConfig(); /* Performing the Pin Multiplexing for UART0 instance. */ UARTPinMuxSetup(0); /* Performing a module reset. */ UARTModuleReset(SOC_UART_0_REGS); /* Performing Baud Rate settings. */ UartBaudRateSet(); /* Switching to Configuration Mode B. */ UARTRegConfigModeEnable(SOC_UART_0_REGS, UART_REG_CONFIG_MODE_B); /* Programming the Line Characteristics. */ UARTLineCharacConfig(SOC_UART_0_REGS, (UART_FRAME_WORD_LENGTH_8 | UART_FRAME_NUM_STB_1), UART_PARITY_NONE); /* Disabling write access to Divisor Latches. */ UARTDivisorLatchDisable(SOC_UART_0_REGS); /* Disabling Break Control. */ UARTBreakCtl(SOC_UART_0_REGS, UART_BREAK_COND_DISABLE); /* Switching to UART16x operating mode. */ UARTOperatingModeSelect(SOC_UART_0_REGS, UART16x_OPER_MODE); /* Performing FIFO configurations. */ UartFIFOConfigure(); /* Preparing the 'intFlags' variable to be passed as an argument.*/ intFlags |= (UART_INT_LINE_STAT | UART_INT_RHR_CTI); /* Enable the Interrupts in UART.*/ UARTIntEnable(SOC_UART_0_REGS, intFlags); // // Main application loop. // while(1) { // // Have we been asked to update the status display? // if(g_ulFlags & COMMAND_STATUS_UPDATE) { // // Clear the command flag // Intstatus = IntDisable(); g_ulFlags &= ~COMMAND_STATUS_UPDATE; IntEnable(Intstatus); DisplayStatus(&g_sContext, g_pcStatus); } // // Has there been any transmit traffic since we last checked? // if(ulTxCount != g_ulUARTTxCount) { // // Take a snapshot of the latest transmit count. // ulTxCount = g_ulUARTTxCount; // // Update the display of bytes transmitted by the UART. // usnprintf(pcBuffer, 16, "%d ", ulTxCount); GrStringDraw(&g_sContext, pcBuffer, -1, 150, 80, true); // // Update the RX buffer fullness. Remember that the buffers are // named relative to the USB whereas the status display is from // the UART's perspective. The USB's receive buffer is the UART's // transmit buffer. // ulFullness = ((USBBufferDataAvailable(&g_sRxBuffer) * 100) / UART_BUFFER_SIZE); UpdateBufferMeter(&g_sContext, ulFullness, 150, 105); } // // Has there been any receive traffic since we last checked? // if(ulRxCount != g_ulUARTRxCount) { // // Take a snapshot of the latest receive count. // ulRxCount = g_ulUARTRxCount; // // Update the display of bytes received by the UART. // usnprintf(pcBuffer, 16, "%d ", ulRxCount); GrStringDraw(&g_sContext, pcBuffer, -1, 150, 160, true); // // Update the TX buffer fullness. Remember that the buffers are // named relative to the USB whereas the status display is from // the UART's perspective. The USB's transmit buffer is the UART's // receive buffer. // ulFullness = ((USBBufferDataAvailable(&g_sTxBuffer) * 100) / UART_BUFFER_SIZE); UpdateBufferMeter(&g_sContext, ulFullness, 150, 185); } } }
//***************************************************************************** // // This is the main application entry function. // //***************************************************************************** int main(void) { unsigned long ulTxCount; unsigned long ulRxCount; tRectangle sRect; char pcBuffer[16]; // // Set the clocking to run from the PLL at 50MHz // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); #ifdef DEBUG // // Configure the relevant pins such that UART0 owns them. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Open UART0 for debug output. // UARTStdioInit(0); #endif // // Not configured initially. // g_bUSBConfigured = false; // // Initialize the display driver. // Formike128x128x16Init(); // // Turn on the backlight. // Formike128x128x16BacklightOn(); // // Initialize the graphics context. // GrContextInit(&g_sContext, &g_sFormike128x128x16); // // Fill the top 15 rows of the screen with blue to create the banner. // sRect.sXMin = 0; sRect.sYMin = 0; sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.sYMax = 14; GrContextForegroundSet(&g_sContext, ClrDarkBlue); GrRectFill(&g_sContext, &sRect); // // Put a white box around the banner. // GrContextForegroundSet(&g_sContext, ClrWhite); GrRectDraw(&g_sContext, &sRect); // // Put the application name in the middle of the banner. // GrContextFontSet(&g_sContext, g_pFontFixed6x8); GrStringDrawCentered(&g_sContext, "usb_dev_bulk", -1, GrContextDpyWidthGet(&g_sContext) / 2, 7, 0); // // Show the various static text elements on the color STN display. // GrContextFontSet(&g_sContext, TEXT_FONT); GrStringDraw(&g_sContext, "Tx bytes:", -1, 8, 70, false); GrStringDraw(&g_sContext, "Rx bytes:", -1, 8, 90, false); // // Configure the USB mux on the board to put us in device mode. We pull // the relevant pin high to do this. // ROM_SysCtlPeripheralEnable(USB_MUX_GPIO_PERIPH); ROM_GPIOPinTypeGPIOOutput(USB_MUX_GPIO_BASE, USB_MUX_GPIO_PIN); ROM_GPIOPinWrite(USB_MUX_GPIO_BASE, USB_MUX_GPIO_PIN, USB_MUX_SEL_DEVICE); // // Enable the system tick. // ROM_SysTickPeriodSet(SysCtlClockGet() / SYSTICKS_PER_SECOND); ROM_SysTickIntEnable(); ROM_SysTickEnable(); // // Show the application name on the display and UART output. // DEBUG_PRINT("\nStellaris USB bulk device example\n"); DEBUG_PRINT("---------------------------------\n\n"); // // Tell the user what we are up to. // DisplayStatus(&g_sContext, "Configuring USB..."); // // Initialize the transmit and receive buffers. // USBBufferInit((tUSBBuffer *)&g_sTxBuffer); USBBufferInit((tUSBBuffer *)&g_sRxBuffer); // // Pass our device information to the USB library and place the device // on the bus. // USBDBulkInit(0, (tUSBDBulkDevice *)&g_sBulkDevice); // // Wait for initial configuration to complete. // DisplayStatus(&g_sContext, "Waiting for host..."); // // Clear our local byte counters. // ulRxCount = 0; ulTxCount = 0; // // Main application loop. // while(1) { // // Have we been asked to update the status display? // if(g_ulFlags & COMMAND_STATUS_UPDATE) { // // Clear the command flag // g_ulFlags &= ~COMMAND_STATUS_UPDATE; DisplayStatus(&g_sContext, g_pcStatus); } // // Has there been any transmit traffic since we last checked? // if(ulTxCount != g_ulTxCount) { // // Take a snapshot of the latest transmit count. // ulTxCount = g_ulTxCount; // // Update the display of bytes transmitted by the UART. // usnprintf(pcBuffer, 16, "%d", ulTxCount); GrStringDraw(&g_sContext, pcBuffer, -1, 70, 70, true); } // // Has there been any receive traffic since we last checked? // if(ulRxCount != g_ulRxCount) { // // Take a snapshot of the latest receive count. // ulRxCount = g_ulRxCount; // // Update the display of bytes received by the UART. // usnprintf(pcBuffer, 16, "%d", ulRxCount); GrStringDraw(&g_sContext, pcBuffer, -1, 70, 90, true); } } }
/***************************************************************************** * * This is the main loop that runs the application. * *****************************************************************************/ int main(void) { tRectangle sRect; MMUConfigAndEnable(); /* Enable USB module clock */ USB0ModuleClkConfig(); /* configures arm interrupt controller to generate raster interrupt */ USBInterruptEnable(); /* LCD Back light setup */ LCDBackLightEnable(); /* UPD Pin setup */ UPDNPinControl(); /* Delay timer setup */ DelayTimerSetup(); /* Configures raster to display image */ SetUpLCD(); /* Configures raster to display image and Copy palette info into buffer */ LCDInit(); GrOffScreen24BPPInit(&g_s35_800x480x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT); /* Initialize a drawing context. */ GrContextInit(&g_sContext, &g_s35_800x480x24Display); /* enable End of frame interrupt */ RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS); /* enable raster */ RasterEnable(SOC_LCDC_0_REGS); /* Fill the top 24 rows of the screen with blue to create the banner. */ sRect.sXMin = 0; sRect.sYMin = 0; sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.sYMax = (MAX_ROW_NUM - 1); GrContextForegroundSet(&g_sContext, ClrDarkBlue); GrRectFill(&g_sContext, &sRect); /* Put a white box around the banner. */ GrContextForegroundSet(&g_sContext, ClrWhite); GrRectDraw(&g_sContext, &sRect); /* Put the application name in the middle of the banner. */ GrContextFontSet(&g_sContext, &g_sFontCm20); GrStringDrawCentered(&g_sContext, "usb-dev-composite", -1, GrContextDpyWidthGet(&g_sContext) / 2, 10, 0); /* Show the various static text elements on the color STN display. */ GrContextFontSet(&g_sContext, TEXT_FONT); GrContextForegroundSet(&g_sContext, ClrViolet); GrStringDraw(&g_sContext, "CDC Serial 1 :-", -1, CDC1_STR_X_POSITION, CDC1_STR_Y_POSITION, false); GrStringDraw(&g_sContext, "CDC Serial 2 :-", -1, CDC2_STR_X_POSITION, CDC1_STR_Y_POSITION, false); GrContextForegroundSet(&g_sContext, ClrWhite); GrStringDraw(&g_sContext, "Tx bytes:", -1, CDC1_STR_X_POSITION, (CDC1_STR_Y_POSITION + CDC_STR_Y_DIFF), false); GrStringDraw(&g_sContext, "Tx buffer:", -1, CDC1_STR_X_POSITION, (CDC1_STR_Y_POSITION + (CDC_STR_Y_DIFF * 2)), false); GrStringDraw(&g_sContext, "Rx bytes:", -1, CDC1_STR_X_POSITION, (CDC1_STR_Y_POSITION + (CDC_STR_Y_DIFF * 4)), false); GrStringDraw(&g_sContext, "Rx buffer:", -1, CDC1_STR_X_POSITION, (CDC1_STR_Y_POSITION + (CDC_STR_Y_DIFF * 5)), false); DrawBufferMeter(&g_sContext, CDC1_BUF_METER_X_POS, CDC1_BUF_METER_Y_POS); DrawBufferMeter(&g_sContext, CDC1_BUF_METER_X_POS, (CDC1_BUF_METER_Y_POS + CDC_BUF_METER_Y_DIFF)); GrStringDraw(&g_sContext, "Tx bytes:", -1, CDC2_STR_X_POSITION, (CDC2_STR_Y_POSITION + CDC_STR_Y_DIFF), false); GrStringDraw(&g_sContext, "Tx buffer:", -1, CDC2_STR_X_POSITION, (CDC2_STR_Y_POSITION + (CDC_STR_Y_DIFF * 2)), false); GrStringDraw(&g_sContext, "Rx bytes:", -1, CDC2_STR_X_POSITION, (CDC2_STR_Y_POSITION + (CDC_STR_Y_DIFF * 4)), false); GrStringDraw(&g_sContext, "Rx buffer:", -1, CDC2_STR_X_POSITION, (CDC2_STR_Y_POSITION + (CDC_STR_Y_DIFF * 5)), false); DrawBufferMeter(&g_sContext, CDC2_BUF_METER_X_POS, CDC2_BUF_METER_Y_POS); DrawBufferMeter(&g_sContext, CDC2_BUF_METER_X_POS, (CDC2_BUF_METER_Y_POS + CDC_BUF_METER_Y_DIFF)); DisplayStatus(&g_sContext, " Waiting for host... "); /* Pass the USB library our device information, initialize the USB controller and connect the device to the bus. */ g_psCompDevices[0].pvInstance = USBDCDCCompositeInit(0, (tUSBDCDCDevice *)&g_sCDCDevice1); g_psCompDevices[1].pvInstance = USBDCDCCompositeInit(0, (tUSBDCDCDevice *)&g_sCDCDevice2); /* Pass the device information to the USB library and place the device on the bus. */ USBDCompositeInit(0, &g_sCompDevice, DESCRIPTOR_DATA_SIZE, g_pucDescriptorData); /* Initialize the serial devices. */ SerialInit(); /* Drop into the main loop. */ while(1) { /* Allow the main serial routine to run. */ SerialMain(); } }
//***************************************************************************** // // This is the main application entry function. // //***************************************************************************** int main(void) { unsigned int ulTxCount; unsigned int ulRxCount; tRectangle sRect; char pcBuffer[16]; unsigned int i; unsigned char *src, *dest; MMUConfigAndEnable(); // // USB module clock enable // USB0ModuleClkConfig(); // //USB interrupt enable // USBInterruptEnable(); // //LCD back light enable // LCDBackLightEnable(); // UPD Pin setup // // UPDNPinControl(); // //Delay timer setup // DelayTimerSetup(); // //Configures raster to display image // SetUpLCD(); RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int)(g_pucBuffer+PALETTE_OFFSET), (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET, FRAME_BUFFER_0); RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int)(g_pucBuffer+PALETTE_OFFSET), (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET, FRAME_BUFFER_1); src = (unsigned char *) palette_32b; dest = (unsigned char *) (g_pucBuffer+PALETTE_OFFSET); // Copy palette info into buffer for( i = PALETTE_OFFSET; i < (PALETTE_SIZE+PALETTE_OFFSET); i++) { *dest++ = *src++; } GrOffScreen24BPPInit(&g_s35_800x480x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT); // Initialize a drawing context. GrContextInit(&g_sContext, &g_s35_800x480x24Display); /* enable End of frame interrupt */ RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS); /* enable raster */ RasterEnable(SOC_LCDC_0_REGS); // // Fill the top 15 rows of the screen with blue to create the banner. // sRect.sXMin = 0; sRect.sYMin = 0; sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.sYMax = 23; GrContextForegroundSet(&g_sContext, ClrDarkBlue); GrRectFill(&g_sContext, &sRect); // // Put a white box around the banner. // GrContextForegroundSet(&g_sContext, ClrWhite); GrRectDraw(&g_sContext, &sRect); // // Put the application name in the middle of the banner. // GrContextFontSet(&g_sContext, &g_sFontCm20); GrStringDrawCentered(&g_sContext, "usb-dev-bulk", -1, GrContextDpyWidthGet(&g_sContext) / 2, 10, 0); // // Show the various static text elements on the color STN display. // GrContextFontSet(&g_sContext, TEXT_FONT); GrStringDraw(&g_sContext, "Tx bytes:", -1, 8, 100, false); GrStringDraw(&g_sContext, "Rx bytes:", -1, 8, 130, false); // // Tell the user what we are up to. // DisplayStatus(&g_sContext, " Configuring USB... "); // // Initialize the transmit and receive buffers. // USBBufferInit((tUSBBuffer *)&g_sTxBuffer); USBBufferInit((tUSBBuffer *)&g_sRxBuffer); // // Pass our device information to the USB library and place the device // on the bus. // USBDBulkInit(0, (tUSBDBulkDevice *)&g_sBulkDevice); // // Wait for initial configuration to complete. // DisplayStatus(&g_sContext, "Waiting for host..."); // // Clear our local byte counters. // ulRxCount = 0; ulTxCount = 0; // // Main application loop. // while(1) { // // Have we been asked to update the status display? // if(g_ulFlags & COMMAND_STATUS_UPDATE) { // // Clear the command flag // g_ulFlags &= ~COMMAND_STATUS_UPDATE; DisplayStatus(&g_sContext, g_pcStatus); } // // Has there been any transmit traffic since we last checked? // if(ulTxCount != g_ulTxCount) { // // Take a snapshot of the latest transmit count. // ulTxCount = g_ulTxCount; // // Update the display of bytes transmitted by the UART. // usnprintf(pcBuffer, 16, " %d ", ulTxCount); GrStringDraw(&g_sContext, pcBuffer, -1, 120, 100, true); } // // Has there been any receive traffic since we last checked? // if(ulRxCount != g_ulRxCount) { // // Take a snapshot of the latest receive count. // ulRxCount = g_ulRxCount; // // Update the display of bytes received by the UART. // usnprintf(pcBuffer, 16, " %d ", ulRxCount); GrStringDraw(&g_sContext, pcBuffer, -1, 120, 130, true); } } }
void EDA_3D_CANVAS::SetView3D( int keycode ) { int ii; double delta_move = 0.7 * g_Parm_3D_Visu.m_Zoom; switch( keycode ) { case WXK_LEFT: m_draw3dOffset.x -= delta_move; break; case WXK_RIGHT: m_draw3dOffset.x += delta_move; break; case WXK_UP: m_draw3dOffset.y += delta_move; break; case WXK_DOWN: m_draw3dOffset.y -= delta_move; break; case WXK_HOME: g_Parm_3D_Visu.m_Zoom = 1.0; m_draw3dOffset.x = m_draw3dOffset.y = 0; trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 ); break; case WXK_END: break; case WXK_F1: g_Parm_3D_Visu.m_Zoom /= 1.4; if( g_Parm_3D_Visu.m_Zoom <= 0.01 ) g_Parm_3D_Visu.m_Zoom = 0.01; break; case WXK_F2: g_Parm_3D_Visu.m_Zoom *= 1.4; break; case '+': break; case '-': break; case 'r': case 'R': m_draw3dOffset.x = m_draw3dOffset.y = 0; for( ii = 0; ii < 4; ii++ ) g_Parm_3D_Visu.m_Rot[ii] = 0.0; trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 ); break; case 'x': for( ii = 0; ii < 4; ii++ ) g_Parm_3D_Visu.m_Rot[ii] = 0.0; trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 ); g_Parm_3D_Visu.m_ROTZ = -90; g_Parm_3D_Visu.m_ROTX = -90; break; case 'X': for( ii = 0; ii < 4; ii++ ) g_Parm_3D_Visu.m_Rot[ii] = 0.0; trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 ); g_Parm_3D_Visu.m_ROTZ = 90; g_Parm_3D_Visu.m_ROTX = -90; break; case 'y': for( ii = 0; ii < 4; ii++ ) g_Parm_3D_Visu.m_Rot[ii] = 0.0; trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 ); g_Parm_3D_Visu.m_ROTX = -90; break; case 'Y': for( ii = 0; ii < 4; ii++ ) g_Parm_3D_Visu.m_Rot[ii] = 0.0; trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 ); g_Parm_3D_Visu.m_ROTX = -90; g_Parm_3D_Visu.m_ROTZ = -180; break; case 'z': for( ii = 0; ii < 4; ii++ ) g_Parm_3D_Visu.m_Rot[ii] = 0.0; trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 ); break; case 'Z': for( ii = 0; ii < 4; ii++ ) g_Parm_3D_Visu.m_Rot[ii] = 0.0; trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 ); g_Parm_3D_Visu.m_ROTX = -180; break; default: return; } DisplayStatus(); Refresh( false ); }
//***************************************************************************** // // This is the main loop that runs the application. // //***************************************************************************** int main(void) { uint8_t ui8ButtonsChanged, ui8Buttons; uint32_t ui32SysClock; // // Set the clocking to run from the PLL at 120MHz // ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_25MHZ | SYSCTL_CFG_VCO_480), 120000000); // // Configure the device pins. // PinoutSet(); // // Configure the buttons driver. // ButtonsInit(ALL_BUTTONS); // // Initialize the display driver. // Kentec320x240x16_SSD2119Init(ui32SysClock); // // Initialize the graphics context. // GrContextInit(&g_sContext, &g_sKentec320x240x16_SSD2119); // // Draw the application frame. // FrameDraw(&g_sContext, "usb-dev-gamepad"); // // Default status is disconnected. // DisplayStatus(&g_sContext, "Disconnected"); // // Not configured initially. // g_iGamepadState = eStateNotConfigured; // // Initialize the USB stack for device mode. // USBStackModeSet(0, eUSBModeDevice, 0); // // Pass the device information to the USB library and place the device // on the bus. // USBDHIDGamepadInit(0, &g_sGamepadDevice); // // Zero out the initial report. // g_sReport.ui8Buttons = 0; g_sReport.i8XPos = 0; g_sReport.i8YPos = 0; // // Initialize the touch screen driver. // TouchScreenInit(ui32SysClock); // // Set the touch screen event handler. // TouchScreenCallbackSet(TSHandler); // // The main loop starts here. We begin by waiting for a host connection // then drop into the main gamepad handling section. If the host // disconnects, we return to the top and wait for a new connection. // while(1) { // // Wait here until USB device is connected to a host. // if(g_iGamepadState == eStateIdle) { // // See if the buttons updated. // ButtonsPoll(&ui8ButtonsChanged, &ui8Buttons); g_sReport.ui8Buttons = 0; // // Set button 1 if up button pressed. // if(ui8Buttons & UP_BUTTON) { g_sReport.ui8Buttons |= 0x01; } // // Set button 2 if down button pressed. // if(ui8Buttons & DOWN_BUTTON) { g_sReport.ui8Buttons |= 0x02; } // // Set button 3 if select button pressed. // if(ui8Buttons & SELECT_BUTTON) { g_sReport.ui8Buttons |= 0x04; } if(ui8ButtonsChanged) { g_bUpdate = true; } // // Send the report if there was an update. // if(g_bUpdate) { g_bUpdate = false; USBDHIDGamepadSendReport(&g_sGamepadDevice, &g_sReport, sizeof(g_sReport)); // // Now sending data but protect this from an interrupt since // it can change in interrupt context as well. // IntMasterDisable(); g_iGamepadState = eStateSending; IntMasterEnable(); } } } }
//***************************************************************************** // // Handles asynchronous events from the HID gamepad driver. // // \param pvCBData is the event callback pointer provided during // USBDHIDGamepadInit(). This is a pointer to our gamepad device structure // (&g_sGamepadDevice). // \param ui32Event identifies the event we are being called back for. // \param ui32MsgData is an event-specific value. // \param pvMsgData is an event-specific pointer. // // This function is called by the HID gamepad driver to inform the application // of particular asynchronous events related to operation of the gamepad HID // device. // // \return Returns 0 in all cases. // //***************************************************************************** uint32_t GamepadHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgData, void *pvMsgData) { switch (ui32Event) { // // The host has connected to us and configured the device. // case USB_EVENT_CONNECTED: { g_iGamepadState = eStateIdle; DisplayStatus(&g_sContext, "Connected"); break; } // // The host has disconnected from us. // case USB_EVENT_DISCONNECTED: { g_iGamepadState = eStateNotConfigured; DisplayStatus(&g_sContext, "Disconnected"); break; } // // This event occurs every time the host acknowledges transmission // of a report. It is to return to the idle state so that a new report // can be sent to the host. // case USB_EVENT_TX_COMPLETE: { // // Enter the idle state since we finished sending something. // g_iGamepadState = eStateIdle; break; } // // This event indicates that the host has suspended the USB bus. // case USB_EVENT_SUSPEND: { // // Go to the suspended state. // g_iGamepadState = eStateSuspend; DisplayStatus(&g_sContext, "Suspended"); break; } // // This event signals that the host has resumed signaling on the bus. // case USB_EVENT_RESUME: { // // Go back to the idle state. // g_iGamepadState = eStateIdle; DisplayStatus(&g_sContext, "Connected"); break; } // // Return the pointer to the current report. This call is // rarely if ever made, but is required by the USB HID // specification. // case USBD_HID_EVENT_GET_REPORT: { *(void **)pvMsgData = (void *)&g_sReport; break; } // // We ignore all other events. // default: { break; } } return(0); }