int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer //initialize LCD initSPI(); LCDinit(); LCDclear(); //Write to LCD while(1) { write(Message1, 8); Line2(); write(Message2,8); _delay_cycles(100000); scroll(Message1, MessageSize1); scroll(Message2, MessageSize2); LCDclear(); } return 0; }
void AfficheDoc(WinEDA_DrawFrame * frame, const wxString & Doc, const wxString & KeyW) /****************************************************************************/ /* Routine d'affichage de la documentation associee a un composant */ { wxString Line1( wxT("Doc: ")), Line2( wxT("KeyW: ")); int color = BLUE; #if ( (wxMAJOR_VERSION < 2) || ((wxMAJOR_VERSION == 2) && (wxMINOR_VERSION <= 4)) ) frame->MsgPanel->Clear(); #else frame->MsgPanel->ClearBackground(); #endif if ( Doc ) Line1 +=Doc; if ( KeyW ) Line2 += KeyW; frame->MsgPanel->Affiche_1_Parametre(10, Line1, Line2, color); }
void ScreenSaver(void) { randomize(); int gDriver=DETECT, gMode,errorcode; initgraph(&gDriver,&gMode,""); errorcode=graphresult(); if(errorcode!=grOk) { printf("ERROR: %s\nPress any key to EXIT\n",grapherrormsg(errorcode)); getch(); exit(1); } //******START*********** int x=1,y=1,i=0,j=0,intsymbol,bkColor=0,Color=2; char *symbol; setbkcolor(bkColor); setcolor(Color); unsigned int A_Size=imagesize(553,390,625,467); void *bigTemp=malloc(A_Size); memset(bigTemp,0,sizeof(bigTemp)); getimage(25,10,85,90,bigTemp); setcolor(15); Rect(1,1,100); T(50,15,14); setcolor(15); Line(50,101,266,"v"); Rect(1,370,100); E(50,390,14); setcolor(15); Line(100,420,430,"h"); Rect(530,370,100); A(580,390,2); setcolor(15); Line2(101,50,580,369); Rect(530,1,100); M(580,30,14); setcolor(15); Paraleli(100,100,100,370,"h"); Paraleli(100,100,530,100,"v"); settextstyle(0,0,2); unsigned int T_Size=imagesize(25,10,85,90); unsigned int E_Size=imagesize(25,390,85,465); unsigned int M_Size=imagesize(545,10,625,90); unsigned int temp_Size=imagesize(220,250,281,252); void *T_Array=malloc(T_Size); void *E_Array=malloc(E_Size); void *A_Array=malloc(A_Size); void *M_Array=malloc(M_Size); void *temp_Array=malloc(temp_Size); void *temp_A=malloc(A_Size); memset(T_Array,0,sizeof(T_Array)); memset(E_Array,0,sizeof(E_Array)); memset(A_Array,0,sizeof(A_Array)); memset(M_Array,0,sizeof(M_Array)); memset(temp_Array,0,sizeof(temp_Array)); memset(temp_A,0,sizeof(temp_A)); getimage(25,10,85,90,T_Array); getimage(25,390,85,465,E_Array); getimage(553,390,625,467,A_Array); getimage(545,10,625,90,M_Array); getimage(220,250,281,252,temp_Array); ///*****WORK WITH BITMAPS************ int i_E,j_E,i_A,j_A,i_M,j_M; putimage(380,120,M_Array,COPY_PUT); putimage(380,260,A_Array,COPY_PUT); for(i=150,j=110,i_E=110,j_E=290,i_A=380,j_A=260,i_M=400,j_M=120;(j<220)&&(i_A>280)&&(i_E<220);j++,i_E++,i_A--) { putimage(i,j,T_Array,COPY_PUT); putimage(i_E,j_E,E_Array,COPY_PUT); delay(LETTERSPEED); while((j_E>253)&&(i_M>330)) { putimage(i_E,j_E,E_Array,COPY_PUT); j_E--; putimage(i_M,j_M,M_Array,COPY_PUT); i_M--; } putimage(i_A,j_A,A_Array,COPY_PUT); } while(j_M<240) { putimage(i_M,j_M,M_Array,COPY_PUT); j_M++; if((j_M>200)&&(j_M<220)) i_M--; } for(;j_E>120;j_A--,j_E--,j_M--) { putimage(i_E,j_E,E_Array,COPY_PUT); putimage(i_A+random(2),j_A,A_Array,COPY_PUT); putimage(i_M,j_M,M_Array,COPY_PUT); } setcolor(14); for(;j_E<215;j_E++,j_M++) { putimage(i_E,j_E-1,temp_Array,COPY_PUT); putimage(i_E,j_E,E_Array,COPY_PUT); putimage(i_M+5,j_M,M_Array,COPY_PUT); delay(random(LETTERSPEED*2)); } for(;j_A<270;j_A++) { putimage(i_A,j_A+70,temp_Array,COPY_PUT); putimage(i_A,j_A,A_Array,COPY_PUT); putimage(i_A,j_A-1,temp_Array,COPY_PUT); } for(i=0;i<15;i++) { putimage(i_A,j_A+=5,temp_Array,COPY_PUT); } getimage(280,270,350,350,temp_A); putimage(280,270,bigTemp,COPY_PUT); putimage(280,250,bigTemp,COPY_PUT); putimage(290,245,bigTemp,COPY_PUT); putimage(280,210,temp_A,COPY_PUT); x=(getmaxx()/2)-70,y=getmaxy()-50; //*************************** outtextxy(x,y,"Made by"); outtextxy(x-70,y+20,"Serhiy Radkivskiy"); setcolor(14); //*****CLOSE************ getch(); // free(symbol); memset(T_Array,0,sizeof(T_Array)); memset(E_Array,0,sizeof(E_Array)); memset(A_Array,0,sizeof(A_Array)); memset(M_Array,0,sizeof(M_Array)); memset(temp_Array,0,sizeof(temp_Array)); memset(temp_A,0,sizeof(temp_A)); free(T_Array); free(E_Array); free(A_Array); free(M_Array); free(temp_Array); free(bigTemp); free(temp_A); cleardevice(); closegraph(); }
static int DialogProc(HWND hDlg, int message, WPARAM wParam, LPARAM lParam) { switch(message) { case MSG_INITDIALOG: { tipLabelData_t* tipLabelData; tipLabelData = (tipLabelData_t*)lParam; if(!tipLabelData) { db_error("invalid tipLabelData\n"); return -1; } SetWindowAdditionalData(hDlg, (DWORD)tipLabelData); if(tipLabelData->pLogFont) { SetWindowFont(hDlg, tipLabelData->pLogFont); } if(tipLabelData->full_screen == 1){ SetWindowBkColor(hDlg,FULL_BLACK); }else{ SetWindowBkColor(hDlg, tipLabelData->bgc_widget); } if(tipLabelData->full_screen == 1){ SetWindowElementAttr(GetDlgItem(hDlg, IDC_TITLE), WE_FGC_WINDOW, PIXEL2DWORD(HDC_SCREEN, FULL_BLACK) ); SetWindowElementAttr(GetDlgItem(hDlg, IDC_TEXT), WE_FGC_WINDOW, PIXEL2DWORD(HDC_SCREEN, FULL_BLACK) ); }else{ SetWindowElementAttr(GetDlgItem(hDlg, IDC_TITLE), WE_FGC_WINDOW, PIXEL2DWORD(HDC_SCREEN, tipLabelData->fgc_widget) ); SetWindowElementAttr(GetDlgItem(hDlg, IDC_TEXT), WE_FGC_WINDOW, PIXEL2DWORD(HDC_SCREEN, tipLabelData->fgc_widget) ); } SetTimerEx(hDlg, TIMEOUT_TIMER, tipLabelData->timeoutMs / 10, timerCallback); } break; case MSG_PAINT: { RECT rect; HDC hdc; tipLabelData_t* tipLabelData; hdc = BeginPaint(hDlg); tipLabelData = (tipLabelData_t*)GetWindowAdditionalData(hDlg); GetClientRect(GetDlgItem(hDlg, IDC_TITLE), &rect); if(tipLabelData->full_screen == 1){ SetPenColor(hdc, FULL_BLACK); }else{ SetPenColor(hdc, tipLabelData->linec_title ); } Line2(hdc, 0, RECTH(rect) + 2, RECTW(rect), RECTH(rect) + 2); #if 0 char *filepath=(char *)"/etc/res/others/wifi.png"; LoadBitmapFromFile(HDC_SCREEN, &tipLabelData->bitImage, filepath); FillBoxWithBitmap(hdc,0,0,320,240,&tipLabelData->bitImage); #endif //ShowWindow(hDlg,SW_SHOWNORMAL); EndPaint(hDlg, hdc); } break; case MSG_FONTCHANGED: { PLOGFONT pLogFont; pLogFont = GetWindowFont(hDlg); if(pLogFont) { SetWindowFont(GetDlgItem(hDlg, IDC_TITLE), pLogFont); SetWindowFont(GetDlgItem(hDlg, IDC_TEXT), pLogFont); } } break; case MSG_KEYUP: { switch(wParam) { case CDR_KEY_RIGHT: EndDialog(hDlg, 0); break; case CDR_KEY_LEFT: case CDR_KEY_OK: case CDR_KEY_MODE: break; } } break; case MSG_KEYDOWN: { //EndDialog(hDlg, 0); } break; case MSG_CLOSE_TIP_LABEL: tipLabelData_t* tipLabelData; tipLabelData = (tipLabelData_t*)GetWindowAdditionalData(hDlg); db_info("MSG_CLOSE_LOWPOWER_DIALOG\n"); if(IsTimerInstalled(hDlg, ONE_SHOT_TIMER) == TRUE) { KillTimer(hDlg, ONE_SHOT_TIMER); } if(IsTimerInstalled(hDlg, TIMEOUT_TIMER) == TRUE) { KillTimer(hDlg, TIMEOUT_TIMER); } if (tipLabelData->bitImage.bmBits != NULL){ UnloadBitmap(&tipLabelData->bitImage); } EndDialog(hDlg, 0); break; } return DefaultDialogProc(hDlg, message, wParam, lParam); }
void WaterPorous2D::set(const Side *sd) { Init(sd); sRHS = 0; _length = Line2(sd).getLength(); }
static int msgBoxProc(HWND hDlg, int message, WPARAM wParam, LPARAM lParam ) { MBPrivData* privData; switch(message) { case MSG_FONTCHANGED: { HWND hChild; hChild = GetNextChild(hDlg, 0); while( hChild && (hChild != HWND_INVALID) ) { SetWindowFont(hChild, GetWindowFont(hDlg)); hChild = GetNextChild(hDlg, hChild); } } break; case MSG_INITDIALOG: { unsigned int dwStyle; MessageBox_t* info = (MessageBox_t *)lParam; if(info == NULL) { db_error("invalid info\n"); return -1; } dwStyle = info->dwStyle & MB_TYPEMASK; privData = (MBPrivData*)malloc(sizeof(MBPrivData)); privData->dwStyle = dwStyle; if(privData->dwStyle & MB_OKCANCEL){ privData->IDCSelected = IDC_BUTTON_START + 1; privData->buttonNRs = 2; } else { privData->IDCSelected = IDC_BUTTON_START; privData->buttonNRs = 1; } db_msg("buttonNRs is %d\n", privData->buttonNRs); privData->flag_end_key = info->flag_end_key; privData->linecTitle = info->linecTitle; privData->linecItem = info->linecItem; privData->confirmCallback = info->confirmCallback; privData->confirmData = info->confirmData; privData->msg4ConfirmCallback = info->msg4ConfirmCallback; SetWindowAdditionalData(hDlg, (DWORD)privData); SetWindowFont(hDlg, info->pLogFont); /******* the hilight is the global attibute *******/ gp_hilite_bgc = GetWindowElementPixel(hDlg, WE_BGC_HIGHLIGHT_ITEM); gp_hilite_fgc = GetWindowElementPixel(hDlg, WE_FGC_HIGHLIGHT_ITEM); gp_normal_bgc = info->bgcWidget; gp_normal_fgc = info->fgcWidget; SetWindowBkColor(hDlg, gp_normal_bgc); SetWindowElementAttr(GetDlgItem(hDlg, IDC_TITLE), WE_FGC_WINDOW, Pixel2DWORD(HDC_SCREEN, gp_normal_fgc)); SetWindowElementAttr(GetDlgItem(hDlg, IDC_TEXT), WE_FGC_WINDOW, Pixel2DWORD(HDC_SCREEN, gp_normal_fgc)); SetWindowText(GetDlgItem(hDlg, IDC_TITLE), info->title); SetWindowText(GetDlgItem(hDlg, IDC_TEXT), info->text); for(unsigned int i = 0; i < privData->buttonNRs; i++) { SetWindowElementAttr( GetDlgItem(hDlg, IDC_BUTTON_START + i), WE_FGC_WINDOW, Pixel2DWORD(HDC_SCREEN, gp_normal_fgc)); SetWindowAdditionalData2( GetDlgItem(hDlg, IDC_BUTTON_START + i), (DWORD)info->buttonStr[i]); } } break; case MSG_KEYUP: { privData = (MBPrivData *)GetWindowAdditionalData(hDlg); switch(wParam) { case CDR_KEY_OK: if(privData->flag_end_key == 1) { db_msg("hDlg is %x\n", hDlg); if( (privData->IDCSelected == IDC_BUTTON_START) && privData->confirmCallback) { if(privData->msg4ConfirmCallback) { SetWindowText(GetDlgItem(hDlg, IDC_TEXT), privData->msg4ConfirmCallback); SetTimerEx(hDlg, TIMER_CONFIRM_CALLBACK, 5, timerCallback); SetNullFocus(hDlg); } else { db_msg("confirmCallback\n"); (*privData->confirmCallback)(hDlg , privData->confirmData); db_msg("confirmCallback\n"); } } else { EndDialog(hDlg, privData->IDCSelected); } } break; case CDR_KEY_MENU: case CDR_KEY_MODE: if(privData->flag_end_key == 1) EndDialog(hDlg, IDC_BUTTON_CANCEL); break; case CDR_KEY_LEFT: privData->IDCSelected--; if(privData->IDCSelected < IDC_BUTTON_START) { privData->IDCSelected = IDC_BUTTON_START + privData->buttonNRs - 1; } InvalidateRect(hDlg, NULL, TRUE); break; case CDR_KEY_RIGHT: privData->IDCSelected++; if(privData->IDCSelected > (IDC_BUTTON_START + privData->buttonNRs - 1) ) { privData->IDCSelected = IDC_BUTTON_START; } InvalidateRect(hDlg, NULL, TRUE); break; default: break; } } break; case MSG_KEYDOWN: { RECT rect; GetClientRect(hDlg, &rect); privData = (MBPrivData *)GetWindowAdditionalData(hDlg); switch(wParam) { case CDR_KEY_OK: if(privData->flag_end_key == 0) { db_msg("hDlg is %x\n", hDlg); if( (privData->IDCSelected == IDC_BUTTON_START) && privData->confirmCallback ) { if(privData->msg4ConfirmCallback) { SetWindowText(GetDlgItem(hDlg, IDC_TEXT), privData->msg4ConfirmCallback); SetTimerEx(hDlg, TIMER_CONFIRM_CALLBACK, 5, timerCallback); SetNullFocus(hDlg); } else { db_msg("confirmCallback\n"); (*privData->confirmCallback)(hDlg , privData->confirmData); db_msg("confirmCallback\n"); } } else { EndDialog(hDlg, privData->IDCSelected); } } break; case CDR_KEY_MENU: case CDR_KEY_MODE: if(privData->flag_end_key == 0) { EndDialog(hDlg, 0); } break; default: break; } } break; case MSG_PAINT: { RECT rect, rect1; HDC hdc = BeginPaint(hDlg); privData = (MBPrivData *)GetWindowAdditionalData(hDlg); GetClientRect(GetDlgItem(hDlg, IDC_TITLE), &rect); GetClientRect(hDlg, &rect1); /**** draw the line below the title *******/ SetPenColor(hdc, privData->linecTitle ); Line2(hdc, 1, RECTH(rect) + 1, RECTW(rect) - 2, RECTH(rect) + 1); /**** draw the line above the button *******/ SetPenColor(hdc, privData->linecItem ); Line2(hdc, 1, RECTH(rect1) * 3 / 4 - 2, RECTW(rect1) - 2, RECTH(rect1) * 3 / 4 - 2); unsigned int i; for(i = 0; i < privData->buttonNRs; i++) { if(IDC_BUTTON_START + i == privData->IDCSelected) { drawButton(hDlg, IDC_BUTTON_START + i, BUTTON_SELECTED); } else { drawButton(hDlg, IDC_BUTTON_START + i, BUTTON_UNSELECTED); } } EndPaint(hDlg, hdc); } break; case MSG_DESTROY: { db_msg("msg destroy"); privData = (MBPrivData *)GetWindowAdditionalData(hDlg); if(privData) free(privData); } break; case MSG_CLOSE_TIP_LABEL: EndDialog(hDlg, 0); break; default: break; } return DefaultDialogProc (hDlg, message, wParam, lParam); }
int main(void) { POWER_ON(); // Turn the regulator ON PWRMODE_SETUP(); // Setup PWRMODE jumper input lcd_init(); // init LCD uint8_t tmp; ADCSRA = (1<<ADEN) | (1<<ADPS1) | (1<<ADPS0); // Enable ADC, set Prescale to 8 unsigned int rhval = eeprom_read_word(&R_H_VAL); // R_H unsigned int rlval = eeprom_read_word(&R_L_VAL); // R_L ctmode = eeprom_read_byte(&CapTestMode); // Compile time choice of test modes (0x22) cp1 = (ctmode & 12) >> 2; // Capacitor pin 1, DEFAULT 0 cp2 = ctmode & 3; // Capacitor pin 2, DEFAULT 2 ctmode = (ctmode & 48) >> 4; // Capacitor test mode, DEFAULT is 0x02 for all 6 cap tests. wdt_disable(); // Disable watch dog timer. if(MCU_STATUS_REG & (1<<WDRF)) { // Examine for Watchdog RESETs That enters, if the Watchdog 2s were not put back Can occur, lcd_clear(); // if the program in a continuous loop " itself; tangled" has. lcd_eep_string(TestTimedOut); // Message - "Timeout!" _delay_ms(3000); // Wait 3 sec wdt_enable(WDTO_2S); // Wait two seconds; if on power it will reset; on battery it will turn itself off while(1) { POWER_OFF(); // Power down in BAT mode or RESET in PWR mode } } LCDLoadCustomChar(); // Custom indication Diode symbol into LCD load lcd_eep_string(DiodeIcon); // Message - diode icon Line1(); // jump to start of first line start: // re-entry point, if button is re-pressed #ifdef WDT_enabled wdt_enable(WDTO_2S); // Watchdog Timer on, 2 seconds? #endif PartFound = PART_NONE; // Default all results tmpPartFound = PART_NONE; // " " NumOfDiodes = 0; // || PartReady = 0; // || PartMode = 0; // || ca = 0; // || cb = 0; // \/ // -> // Startup Message //////////////////////////////////////// lcd_clear(); // lcd_eep_string(StartupMessage); // LCD: ACT v#.# [XXX] // -> // Power selection and Battery Testing //////////////////// if(PWRMODE_GET()) { // Get the PWRMODE jumper logic PowerMode = PWR_9V; // Set powermode to PWR_9V _delay_us(250); ReadADC(5 | (1<<REFS1)); // Measure the 9V battery Supply ( - diode drop) hfe[0] = ReadADC(5 | (1<<REFS1)); // if in battery mode. lcd_eep_string(BatMode); // Tell user device in BAT mode Line2(); if (hfe[0] < BAT_WEAK) { // Compare 9v reading with BAT_WEAK variable if(hfe[0] < BAT_DEAD) { // If the batter is considered dead then lcd_eep_string(Bat); lcd_eep_string(BatEmpty); // Tell the user battery is DEAD _delay_ms(3000); // Wait a bit. while(1) { // Forever loop POWER_OFF(); // keep trying to kill the power forever. } } lcd_clear(); lcd_eep_string(Bat); // Battery isnt dead; its just weak lcd_eep_string(BatWeak); // tell the user; but keep testing... Line2(); // Start second line } } else { PowerMode = PWR_5V; // Power mode is constent v5, skip battery check. lcd_eep_string(PwrMode); // Tell user we are running in PWR mode. Line2(); } // -> // Begin testing sequince. /////////////////////////////// lcd_eep_string(TestRunning); // Tell user the testing has begun... UpdateProgress("00%"); // Progress at 00% and Testing CheckPins(TP1, TP2, TP3); // || UpdateProgress("16%"); // \/ CheckPins(TP1, TP3, TP2); // TESTING... UpdateProgress("33%"); // CheckPins(TP2, TP1, TP3); // || UpdateProgress("50%"); // \/ CheckPins(TP2, TP3, TP1); // TESTING... UpdateProgress("66%"); // CheckPins(TP3, TP2, TP1); // || UpdateProgress("83%"); // \/ CheckPins(TP3, TP1, TP2); // Almost there! UpdateProgress("99%"); // Testing Completed or 99% //---------------------------------------------CAPACITOR--------------------------------------- // Separate measurement to the test on condenser if(((PartFound == PART_NONE) || (PartFound == PART_RESISTOR) || (PartFound == PART_DIODE)) && (ctmode > 0)) { // Condenser unload; otherwise possibly no measurement is possible R_PORT = 0; R_DDR = (1<<(TP1 * 2)) | (1<<(TP2 * 2)) | (1<<(TP3 * 2)); _delay_ms(10); R_DDR = 0; if(ctmode == NORMAL_CAP_TESTS) { // see if we want to do all 6 Cap Tests ReadCapacity(cp1, cp2); // No - just read the pins both ways. ReadCapacity(cp2, cp1); } else { // DEFAULT ctmode == 0x02 to do all tests Line2(); lcd_eep_string(TestCapV); UpdateProgress("00%"); ReadCapacity(TP3, TP1); UpdateProgress("16%"); ReadCapacity(TP3, TP2); UpdateProgress("33%"); ReadCapacity(TP2, TP3); UpdateProgress("50%"); ReadCapacity(TP2, TP1); UpdateProgress("66%"); ReadCapacity(TP1, TP3); UpdateProgress("83%"); ReadCapacity(TP1, TP2); UpdateProgress("99%"); } } lcd_clear(); // Finished, now evaluate, the results //---------------------------------------------DIODE------------------------------------------------ if(PartFound == PART_DIODE) { if(NumOfDiodes == 1) { // Standard-Diode lcd_eep_string(Diode); // Message - "Diode: " lcd_eep_string(Anode); // Message - "A=" lcd_data(GetPinAlias(diodes[0].Anode + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(NextK); // Message - ";C=" lcd_data(GetPinAlias(diodes[0].Cathode + ASCII_1)); // Display 1, 2, or 3 Line2(); // Start second line lcd_eep_string(Uf); // Message - "Uf=" lcd_string(itoa(diodes[0].Voltage, outval, 10)); lcd_eep_string(mV); // Message - "mV" goto end; } else if(NumOfDiodes == 2) { // dual diode if(diodes[0].Anode == diodes[1].Anode) { // Common Anode lcd_eep_string(DualDiode); // Message - "Double diode €" lcd_eep_string(CA); // Message - "CA" Line2(); // Start second line lcd_eep_string(Anode); // Message - "A=" lcd_data(GetPinAlias(diodes[0].Anode + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(K1); // Message - ";C1=" lcd_data(GetPinAlias(diodes[0].Cathode + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(K2); // Message - ";C2=" lcd_data(GetPinAlias(diodes[1].Cathode + ASCII_1)); // Display 1, 2, or 3 goto end; } else if(diodes[0].Cathode == diodes[1].Cathode) { // Common Cathode lcd_eep_string(DualDiode); // Message - "Double diode €" lcd_eep_string(CC); // Message - "CC" Line2(); // Start second line lcd_eep_string(K); // Message - "C=" lcd_data(GetPinAlias(diodes[0].Cathode + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(A1); // Message - ";A1=" lcd_data(GetPinAlias(diodes[0].Anode + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(A2); // Message - ";A2=" lcd_data(GetPinAlias(diodes[1].Anode + ASCII_1)); // Display 1, 2, or 3 goto end; } else if ((diodes[0].Cathode == diodes[1].Anode) && \ (diodes[1].Cathode == diodes[0].Anode)) { // Antiparallel lcd_eep_string(TwoDiodes); // Message - "2 diodes" Line2(); // Start second line lcd_eep_string(Antiparallel); // Message - "anti-parallel" goto end; } } else if(NumOfDiodes == 3) { // Series connection from 2 diodes; as 3 diodes one recognizes b = 3; c = 3; // Check to see if it is series connection of 2 diodes. // But 2 cathodes, and 2 anodes must agree. // Then the 2 diodes are a single dual-diode. if((diodes[0].Anode == diodes[1].Anode) || (diodes[0].Anode == diodes[2].Anode)) b = diodes[0].Anode; if(diodes[1].Anode == diodes[2].Anode) b = diodes[1].Anode; if((diodes[0].Cathode == diodes[1].Cathode) || (diodes[0].Cathode == diodes[2].Cathode)) c = diodes[0].Cathode; if(diodes[1].Cathode == diodes[2].Cathode) c = diodes[1].Cathode; if((b<3) && (c<3)) { lcd_eep_string(TwoDiodes); // Message - "2 diodes" Line2(); // Start second line lcd_eep_string(InSeries); // Message - "serial A=€€" lcd_data(GetPinAlias(b + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(NextK); // Message - ";C=" lcd_data(GetPinAlias(c + ASCII_1)); // Display 1, 2, or 3 goto end; } } } //---------------------------------------------TRANSISTOR-------------------------------------------- else if (PartFound == PART_TRANSISTOR) { if(PartReady == 0) { // 2nd examination never made, e.g. a transistor with protection diode. hfe[1] = hfe[0]; uBE[1] = uBE[0]; } if((hfe[0]>hfe[1])) { // If the amplification factor with the first test was higher: swap C and E hfe[1] = hfe[0]; uBE[1] = uBE[0]; tmp = c; c = e; e = tmp; } if(PartMode == PART_MODE_NPN) lcd_eep_string(NPN); // Message - "NPN" else lcd_eep_string(PNP); // Message - "PNP" lcd_eep_string(bstr); // Message - " B=" lcd_data(GetPinAlias(b + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(cstr); // Message - ";C=" lcd_data(GetPinAlias(c + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(estr); // Message - ";E=" lcd_data(GetPinAlias(e + ASCII_1)); // Display 1, 2, or 3 Line2(); // Start second line // Amplification factor compute, hFE = Emitter current/base current lhfe = hfe[1]; lhfe *= (((unsigned long)rhval * 100) / (unsigned long)rlval); // 500000/750 = 666.666r if(uBE[1]<11) uBE[1] = 11; lhfe /= uBE[1]; hfe[1] = (unsigned int) lhfe; lcd_eep_string(hfestr); // Message - "hFE=" lcd_string(utoa(hfe[1], outval, 10)); SetCursor(2,7); // Cursor on line 2, character 7 if(NumOfDiodes > 2) // Transistor with protection diode lcd_data(LCD_CHAR_DIODE); // Diode indicate else lcd_data(' '); for(c=0;c<NumOfDiodes;c++) { if(( (diodes[c].Cathode == e) && (diodes[c].Anode == b) && \ (PartMode == PART_MODE_NPN)) || ((diodes[c].Anode == e) && \ (diodes[c].Cathode == b) && (PartMode == PART_MODE_PNP))) { lcd_eep_string(Uf); // Message - "Uf=" lcd_string(itoa(diodes[c].Voltage, outval, 10)); lcd_data('m'); goto end; } } goto end; } //---------------------------------------------FET--------------------------------------------------- else if (PartFound == PART_FET) { // JFET or MOSFET if(PartMode & 1) // N-channel lcd_data('N'); else lcd_data('P'); // P-channel if((PartMode == PART_MODE_N_D_MOS) || (PartMode == PART_MODE_P_D_MOS)) { lcd_eep_string(dmode); // Message - "-D" lcd_eep_string(mosfet); // Message - "-MOS" } else { if((PartMode == PART_MODE_N_JFET) || (PartMode == PART_MODE_P_JFET)) lcd_eep_string(jfet); // Message - "-JFET" else { lcd_eep_string(emode); // Message - "-E" lcd_eep_string(mosfet); // Message - "-MOS" } } // Gate capacity if(PartMode < 3) { // Enrichment MOSFET lcd_eep_string(GateCap); // Message - " C=" ReadCapacity(b,e); // Measurement hfe[0] = (unsigned int)cv; if(hfe[0]>2) hfe[0] -= 3; utoa(hfe[0], outval2, 10); tmpval = strlen(outval2); tmpval2 = tmpval; if(tmpval>4) tmpval = 4; // If capacity > 100nF drop fractional part to fit on the LCD lcd_show_format_cap(outval2, tmpval, tmpval2); lcd_data('n'); } Line2(); // Start second line lcd_eep_string(gds); // Message - "GDS=" lcd_data(GetPinAlias(b + ASCII_1)); // Display 1, 2, or 3 lcd_data(GetPinAlias(c + ASCII_1)); // Display 1, 2, or 3 lcd_data(GetPinAlias(e + ASCII_1)); // Display 1, 2, or 3 if((NumOfDiodes > 0) && (PartMode < 3)) // MOSFET with protection diode; it gives only with enrichment FETs lcd_data(LCD_CHAR_DIODE); // Diode indicate else lcd_data(' '); // Blank if(PartMode < 3) { // Enrichment MOSFET gthvoltage=(gthvoltage/8); lcd_eep_string(vt); // Message - "Vt=" lcd_string(utoa(gthvoltage, outval, 10)); // Gate threshold voltage, was determined before lcd_data('m'); } goto end; } //---------------------------------------------THYRISTOR--------------------------------------------- else if (PartFound == PART_THYRISTOR) { lcd_eep_string(Thyristor); // Message - "Thyristor" Line2(); // Start second line lcd_eep_string(GAK); // Message - "GAC=" lcd_data(GetPinAlias(b + ASCII_1)); // Display 1, 2, or 3 lcd_data(GetPinAlias(c + ASCII_1)); // Display 1, 2, or 3 lcd_data(GetPinAlias(e + ASCII_1)); // Display 1, 2, or 3 goto end; } //---------------------------------------------TRIAC------------------------------------------------- else if (PartFound == PART_TRIAC) { lcd_eep_string(Triac); // Message - "Triac" Line2(); // Start second line lcd_eep_string(Gate); // Message - "G=" lcd_data(GetPinAlias(b + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(A1); // Message - ";A1=" lcd_data(GetPinAlias(e + ASCII_1)); // Display 1, 2, or 3 lcd_eep_string(A2); // Message - ";A2=" lcd_data(GetPinAlias(c + ASCII_1)); // Display 1, 2, or 3 goto end; } //---------------------------------------------RESISTOR---------------------------------------------- else if(PartFound == PART_RESISTOR) { lcd_eep_string(Resistor); // Message - "Resistor: €€" lcd_data(GetPinAlias(ra + ASCII_1)); // Display 1, 2, or 3 Pin data lcd_data('-'); lcd_data(GetPinAlias(rb + ASCII_1)); // Display 1, 2, or 3 Line2(); // Start second line if(rv[0] > HALF_ADC_RANGE) // Examine, how far the Voltages across the test resistances deviate from 512 hfe[0] = (rv[0] - HALF_ADC_RANGE); else hfe[0] = (HALF_ADC_RANGE - rv[0]); if(rv[1] > HALF_ADC_RANGE) hfe[1] = (rv[1] - HALF_ADC_RANGE); else hfe[1] = (HALF_ADC_RANGE - rv[1]); if(hfe[0] > hfe[1]) { radcmax[0] = radcmax[1]; rv[0] = rv[1]; // Result use, which is more near because of 512 (accuracy improves) rv[1] = rhval; // High - Test resistance } else rv[1] = rlval; // Low - Test resistance if(rv[0] == 0) rv[0] = 1; lhfe = (unsigned long)((unsigned long)((unsigned long)rv[1] * \ (unsigned long)rv[0]) / (unsigned long)((unsigned long)radcmax[0] - (unsigned long)rv[0])); // Resistance compute ultoa(lhfe,outval,10); if(rv[1] == rhval) { // 470k- Resisted? ra = strlen(outval); // Necessarily, in order to indicate comma for(rb=0;rb<ra;rb++) { lcd_data(outval[rb]); if(rb == (ra-2)) lcd_data(','); // comma } lcd_data ('K'); // Kilo ohm, if 470k uses resistance } else lcd_string(outval); lcd_data(LCD_CHAR_OMEGA); // Omega for ohms goto end; } //---------------------------------------------CAPACITOR--------------------------------------------- else if(PartFound == PART_CAPACITOR) { // Capacitor measurement lcd_eep_string(Capacitor); // Message - "Capacitor: €€" lcd_data(GetPinAlias(ca + ASCII_1)); // Display 1, 2, or 3 Pin - Data lcd_data('-'); lcd_data(GetPinAlias(cb + ASCII_1)); // Display 1, 2, or 3 Line2(); // Start second line tmpval2 = 'n'; // n for nF if(cv > 99999) { // Too big cv /= 1000; // convert to Micro Farads tmpval2 = LCD_CHAR_U; // change n to greek char for micro } ultoa(cv, outval, 10); // outval now a string version of cv tmpval = strlen(outval); lcd_show_format_cap(outval, tmpval, tmpval); lcd_data(tmpval2); // display the SI Suffix lcd_data('F'); // F for Farads goto end; } //---------------------------------------------NOT-FOUND-OR-DAMAGED--------------------------------------------------------- if(NumOfDiodes == 0) { // Nothing found. Tell user. lcd_eep_string(TestFailed1); Line2(); lcd_eep_string(TestFailed2); } else { // Data found but bad result or no positive ident lcd_eep_string(BadResult1); Line2(); lcd_eep_string(BadResult2); lcd_data(NumOfDiodes + ASCII_0); lcd_data(LCD_CHAR_DIODE); } end: while(!(ON_PIN_REG & (1<<RST_PIN))); // wait, to tracers released _delay_ms(200); for(hfe[0] = 0;hfe[0]<10000;hfe[0]++) { // 10 Seconds untill power off. if(!(ON_PIN_REG & (1<<RST_PIN))) // if the button is pressed, start all over goto start; wdt_reset(); // We want to wait the full 10 Seconds _delay_ms(1); // 1mS 10,000 times = 10 seconds } if(PowerMode==PWR_9V) { // If in battery mode; try to turn off; otherwise wait for a reset POWER_OFF(); } wdt_disable(); // Watchdog out // Continuous loop, no timer while(1) { if(!(RESET_GET())) // only one reaches, if the automatic disconnection was not inserted goto start; } return 0; } // End of main()
//.x Skimming.C+("Input_2015D_v3_ONE.txt","BB_reduced.root") void Skimming( TString fileList, TString outName ){ //Doing the chain cout<<"Starting... "<<endl; TChain chain_data("cutFlowAnalyzer/Events"); TChain chain_databb("cutFlowAnalyzer/Events_orphan"); std::ifstream Myfile( fileList.Data() ); std::string Line; if( !Myfile ) std::cout<<"ERROR opening "<<fileList<<std::endl; while (std::getline(Myfile, Line)){ TString Line2(Line); if( Line2.Contains("root") ){ chain_data.Add(Line2.Data()); chain_databb.Add(Line2.Data()); } } cout<<"Chain done!"<<endl; //Variables needed bool orph_passOffLineSel_bb, orph_passOffLineSelPt_bb, orph_passOffLineSelPt1788_bb, orph_FiredTrig_bb, orph_FiredTrig_pt_bb, orph_FiredTrig_ptColl_bb; int containstrig2_bb, containstrig_bb; float orph_dimu_mass_bb, orph_dimu_isoTk_bb; chain_databb.SetBranchAddress("orph_passOffLineSel",&orph_passOffLineSel_bb); chain_databb.SetBranchAddress("orph_passOffLineSelPt",&orph_passOffLineSelPt_bb); chain_databb.SetBranchAddress("orph_passOffLineSelPt1788",&orph_passOffLineSelPt1788_bb); chain_databb.SetBranchAddress("orph_FiredTrig",&orph_FiredTrig_bb); chain_databb.SetBranchAddress("orph_FiredTrig_pt",&orph_FiredTrig_pt_bb); chain_databb.SetBranchAddress("orph_FiredTrig_ptColl",&orph_FiredTrig_ptColl_bb); chain_databb.SetBranchAddress("orph_FiredTrig",&orph_FiredTrig_bb); chain_databb.SetBranchAddress("orph_dimu_isoTk",&orph_dimu_isoTk_bb); chain_databb.SetBranchAddress("containstrig2",&containstrig2_bb); chain_databb.SetBranchAddress("orph_dimu_mass",&orph_dimu_mass_bb); chain_databb.SetBranchAddress("containstrig",&containstrig_bb); float massC_mu, massF_mu, isoC_1mm_mu, isoF_1mm_mu; chain_data.SetBranchAddress("massC",&massC_mu); chain_data.SetBranchAddress("massF",&massF_mu); chain_data.SetBranchAddress("isoC_1mm",&isoC_1mm_mu); chain_data.SetBranchAddress("isoF_1mm",&isoF_1mm_mu); //My file TFile *f = new TFile(outName.Data(),"RECREATE"); f->cd(); TTree Events("Events",""); float massC, massF, isoC_1mm, isoF_1mm; Events.Branch("massC",&massC,"massC/F"); Events.Branch("massF",&massF,"massF/F"); Events.Branch("isoC_1mm",&isoC_1mm,"isoC_1mm/F"); Events.Branch("isoF_1mm",&isoF_1mm,"isoF_1mm/F"); bool orph_passOffLineSel, orph_passOffLineSelPt, orph_passOffLineSelPt1788, orph_FiredTrig, orph_FiredTrig_pt, orph_FiredTrig_ptColl; int containstrig2, containstrig; float orph_dimu_mass, orph_dimu_isoTk; TTree Events_orphan("Events_orphan",""); Events_orphan.Branch("orph_passOffLineSel",&orph_passOffLineSel,"orph_passOffLineSel/O"); Events_orphan.Branch("orph_passOffLineSelPt",&orph_passOffLineSelPt,"orph_passOffLineSelPt/O"); Events_orphan.Branch("orph_passOffLineSelPt1788",&orph_passOffLineSelPt1788,"orph_passOffLineSelPt1788/O"); Events_orphan.Branch("orph_FiredTrig",&orph_FiredTrig,"orph_FiredTrig/O"); Events_orphan.Branch("orph_FiredTrig_pt",&orph_FiredTrig_pt,"orph_FiredTrig_pt/O"); Events_orphan.Branch("orph_FiredTrig_ptColl",&orph_FiredTrig_ptColl,"orph_FiredTrig_ptColl/O"); Events_orphan.Branch("containstrig2",&containstrig2,"containstrig2/I"); Events_orphan.Branch("containstrig",&containstrig,"containstrig/I"); Events_orphan.Branch("orph_dimu_isoTk",&orph_dimu_isoTk,"orph_dimu_isoTk/F"); Events_orphan.Branch("orph_dimu_mass",&orph_dimu_mass,"orph_dimu_mass/F"); //Loops cout<<"Now starting loop on bb."<<endl; Long64_t entries = chain_databb.GetEntries(); for(Long64_t i=0; i<entries; i++){ if(i%10000==0) cout<<"i = "<<i<<" / "<<entries<<endl; chain_databb.GetEntry(i); if(orph_dimu_mass>-999.){ orph_passOffLineSel = orph_passOffLineSel_bb; orph_passOffLineSelPt = orph_passOffLineSelPt_bb; orph_passOffLineSelPt1788 = orph_passOffLineSelPt1788_bb; orph_FiredTrig = orph_FiredTrig_bb; orph_FiredTrig_pt = orph_FiredTrig_pt_bb; orph_FiredTrig_ptColl = orph_FiredTrig_ptColl_bb; containstrig2 = containstrig2_bb; containstrig = containstrig_bb; orph_dimu_isoTk = orph_dimu_isoTk_bb; orph_dimu_mass = orph_dimu_mass_bb; Events_orphan.Fill(); } } cout<<"Now starting loop on mu."<<endl; entries = chain_data.GetEntries(); for(Long64_t i=0; i<entries; i++){ if(i%10000==0) cout<<"i = "<<i<<" / "<<entries<<endl; chain_data.GetEntry(i); if(massC_mu>-999. || massF_mu>-999.){ massC = massC_mu; massF = massF_mu; isoC_1mm = isoC_1mm_mu; isoF_1mm = isoF_1mm_mu; Events.Fill(); } } cout<<"CLosing files"<<endl; f->Write(); f->Close(); cout<<"The end."<<endl; }