void checkKeyboard() { uchar delayKeyb = 100; // valore di default uchar KeybValue = 0; uchar loopCounter = 0; bool LOOP = true; while (LOOP) { clear_wdt(); // -- Leggiamo i dati dalla porta if (loopCounter++ > 3) delayKeyb = 1; // Next wait più basso delay_ms(delayKeyb); KeybValue = readPortB47(); displayValues(); switch (KeybValue) { case KEY_FUNC_UP: if (++gcnFunc > FUNC_LAST) gcnFunc = 0; continue; case KEY_FUNC_DN: if (--gcnFunc > FUNC_LAST) gcnFunc = FUNC_LAST; // non controlla il negativo. Quindi lavoro sull'assoluto. continue; case KEY_PULSE_UP: if (fCONTINUOUS_KEY == false) gcnPulse++; // ruota a 256 continue; case KEY_PULSE_DN: if (fCONTINUOUS_KEY == false) gcnPulse--; // ruota a 256 continue; // --------------------------------------------------------------------------------- // Vale solo per misurare +Pulse e -Pulse. // Quando questo è ON allora il numero dell'impulso viene ignorato e // si procede ad una lettura continua. Come se fosse PosWAVE o NegWAVE. // --------------------------------------------------------------------------------- case KEY_CONTINUOUS: LNtoggle_bool(fCONTINUOUS_KEY); // toggle bit continue; case KEY_SET_TMR0: fSET_TMRx = true; LOOP = false; break; default: LOOP = false; break; } // end switch() } // end While() displayValues(); return; }
int main(void) { DDRB = 0x0F; int keyboardPushed = 0; int confirmed = 0; int col = 0; int keyIndex = -100; int keyboard[16] = { 7, 8, 9, 47, 4, 5, 6, 42, 1, 2, 3, 45, -1, 0, -2, 43 }; uint8_t columnIndexes[4] = { 0b11111110, 0b11111101, 0b11111011, 0b11110111 }; lcd_init(); lcd_clrscr(); lcd_home(); while (1) { PORTB = columnIndexes[col]; keyboardPushed = isKeyboardPushed(); keyIndex = getKeyIndex(col); if (keyIndex == -100) { displayValues(); } if (keyboardPushed == 1 && confirmed == 0 && keyIndex != -100) { confirmed = 1; keyHandler(keyboard[keyIndex]); } else if (keyboardPushed == 0 && confirmed == 1) { confirmed = 0; } _delay_ms(25); if (keyboardPushed == 0 && ++col==4) { col=0; } } }
void checkKeyboard() { uchar delayKeyb = 100; // valore di default uchar KeybValue = 0; uchar loopCounter = 0; bool LOOP = true; while (LOOP) { clear_wdt(); // -- Leggiamo i dati dalla porta if (loopCounter++ > 3) delayKeyb = 1; // Next wait più basso delay_ms(delayKeyb); KeybValue = readPortB47(); displayValues(); switch (KeybValue) { // Decide la funzione da utilizzare case KEY_FUNC_UP: if (++gcFuncIndex > LAST_FUNCTION) gcFuncIndex = 0; continue; case KEY_FUNC_DN: if (--gcFuncIndex > LAST_FUNCTION) gcFuncIndex = LAST_FUNCTION; // non controlla il negativo. Quindi lavoro sull'assoluto. continue; case KEY_PULSE_UP: if (fCONTINUOUS_KEY == false) gcPulseNumber++; // ruota a 256 continue; case KEY_PULSE_DN: if (fCONTINUOUS_KEY == false) gcPulseNumber--; // ruota a 256 continue; // --------------------------------------------------------------------------------- // Vale solo per misurare +Pulse e -Pulse. // Quando questo è ON allora il numero dell'impulso viene ignorato e // si procede ad una lettura continua. Come se fosse PosWAVE o NegWAVE. // --------------------------------------------------------------------------------- case KEY_FSCALE: gcGateIndex++; if (gcGateIndex >= MAX_nGATEs) gcGateIndex = 0; pTMR = &stTMR[gcGateIndex]; // change pointer to TMR0 value for the selected scale continue; case KEY_CONTINUOUS: LNtoggle_bool(fCONTINUOUS_KEY); // toggle bit continue; case KEY_SET_TMR0: fSET_TMRx = true; LOOP = false; break; default: LOOP = false; break; } // end switch() } // end While() displayValues(); return; }
void display( nsIRegistry *reg, nsRegistryKey root, const char *rootName ) { // Print out key name. printf( "%s\n", rootName ); // Make sure it isn't a "root" key. if ( root != nsIRegistry::Common && root != nsIRegistry::Users && root != nsIRegistry::CurrentUser ) { // Print values stored under this key. displayValues( reg, root ); } // Enumerate all subkeys (immediately) under the given node. nsIEnumerator *keys; nsresult rv = reg->EnumerateSubtrees( root, &keys ); // Check result. if ( rv == NS_OK ) { // Set enumerator to beginning. rv = keys->First(); // Enumerate subkeys till done. while( NS_SUCCEEDED( rv ) && (NS_OK != keys->IsDone()) ) { nsISupports *base; rv = keys->CurrentItem( &base ); // Test result. if ( rv == NS_OK ) { // Get specific interface. nsIRegistryNode *node; nsIID nodeIID = NS_IREGISTRYNODE_IID; rv = base->QueryInterface( nodeIID, (void**)&node ); // Test that result. if ( rv == NS_OK ) { // Get node name. char *name; rv = node->GetNameUTF8( &name ); // Test result. if ( rv == NS_OK ) { // Build complete name. char *fullName = new char[ PL_strlen(rootName) + PL_strlen(name) + 5 ]; PL_strcpy( fullName, rootName ); PL_strcat( fullName, " - " ); PL_strcat( fullName, name ); // Display contents under this subkey. nsRegistryKey key; rv = reg->GetSubtreeRaw( root, name, &key ); if ( rv == NS_OK ) { display( reg, key, fullName ); printf( "\n" ); } else { printf( "Error getting key, rv=0x%08X\n", (int)rv ); } delete [] fullName; } else { printf( "Error getting subtree name, rv=0x%08X\n", (int)rv ); } // Release node. node->Release(); } else { printf( "Error converting base node ptr to nsIRegistryNode, rv=0x%08X\n", (int)rv ); } // Release item. base->Release(); // Advance to next key. rv = keys->Next(); // Check result. if ( NS_SUCCEEDED( rv ) ) { } else { printf( "Error advancing enumerator, rv=0x%08X\n", (int)rv ); } } else { printf( "Error getting current item, rv=0x%08X\n", (int)rv ); } } // Release key enumerator. keys->Release(); } else { printf( "Error creating enumerator for %s, root=0x%08X, rv=0x%08X\n", rootName, (int)root, (int)rv ); } return; }