gboolean on_entry_key_press_event(GtkEntry *entry, GdkEvent *event) { guint k = GDK_KEY_VoidSymbol; gdk_event_get_keyval(event, &k); GdkModifierType s; gdk_event_get_state(event, &s); #define KEY(S) (k == S) #define CTRL(S) (KEY(S) && s & GDK_CONTROL_MASK) #define SHIFT(S) (KEY(S) && s & GDK_SHIFT_MASK) if (KEY(GDK_KEY_Escape) || CTRL(GDK_KEY_c)) gtk_main_quit(); else if (KEY(GDK_KEY_Tab) || CTRL(GDK_KEY_i)) gtk_entry_set_text(entry, row_text(selected_row())); else if (KEY(GDK_KEY_Down) || CTRL(GDK_KEY_f)) select_row(selected_row() + 1); else if (KEY(GDK_KEY_Up) || CTRL(GDK_KEY_b)) select_row(selected_row() - 1); else if (KEY(GDK_KEY_Return) || CTRL(GDK_KEY_j)) output(row_text(selected_row())); else if (SHIFT(GDK_KEY_Return) || CTRL(GDK_KEY_J)) output(entry_text()); return FALSE; }
uint8_t matrix_scan(void) { if (!debouncing) { uint8_t *tmp = matrix_prev; matrix_prev = matrix; matrix = tmp; } for (uint8_t i = 0; i < MATRIX_ROWS; i++) { unselect_rows(); select_row(i); _delay_us(30); // without this wait read unstable value. if (matrix[i] != (uint8_t)~read_col()) { matrix[i] = (uint8_t)~read_col(); if (debouncing) { debug("bounce!: "); debug_hex(debouncing); print("\n"); } debouncing = DEBOUNCE; } } unselect_rows(); if (debouncing) { debouncing--; } return 1; }
static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { // Store last value of row prior to reading matrix_row_t last_row_value = current_matrix[current_row]; // Clear data in matrix row current_matrix[current_row] = 0; // Select row and wait for row selecton to stabilize select_row(current_row); wait_us(30); // For each col... for(uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { // Select the col pin to read (active low) uint8_t pin_state = readPin(col_pins[col_index]); // Populate the matrix row with the state of the col pin current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index); } // Unselect row unselect_row(current_row); return (last_row_value != current_matrix[current_row]); }
uint8_t _matrix_scan(void) { // Right hand is stored after the left in the matirx so, we need to offset it int offset = isLeftHand ? 0 : (ROWS_PER_HAND); for (uint8_t i = 0; i < ROWS_PER_HAND; i++) { select_row(i); _delay_us(30); // without this wait read unstable value. matrix_row_t cols = read_cols(); if (matrix_debouncing[i+offset] != cols) { matrix_debouncing[i+offset] = cols; if (debouncing) { debug("bounce!: "); debug_hex(debouncing); debug("\n"); } debouncing = DEBOUNCE; } unselect_rows(); } if (debouncing) { if (--debouncing) { _delay_ms(1); } else { for (uint8_t i = 0; i < ROWS_PER_HAND; i++) { matrix[i+offset] = matrix_debouncing[i+offset]; } } } return 1; }
uint8_t matrix_scan(void) { for (uint8_t i = 0; i < MATRIX_ROWS; i++) { select_row(i); _delay_us(30); // without this wait read unstable value. matrix_row_t cols = read_cols(); if (matrix_debouncing[i] != cols) { matrix_debouncing[i] = cols; if (debouncing) { debug("bounce!: "); debug_hex(debouncing); debug("\n"); } debouncing = DEBOUNCE; } unselect_rows(); } if (debouncing) { if (--debouncing) { _delay_ms(1); } else { for (uint8_t i = 0; i < MATRIX_ROWS; i++) { matrix[i] = matrix_debouncing[i]; } } } return 1; }
uint8_t matrix_scan(void) { if (mcp23018_status) { // if there was an error if (++mcp23018_reset_loop == 0) { // since mcp23018_reset_loop is 8 bit - we'll try to reset once in 255 matrix scans // this will be approx bit more frequent than once per second print("trying to reset mcp23018\n"); mcp23018_status = init_mcp23018(); if (mcp23018_status) { print("left side not responding\n"); } else { print("left side attached\n"); frenchdev_blink_all_leds(); } } } #ifdef DEBUG_MATRIX_SCAN_RATE matrix_scan_count++; uint32_t timer_now = timer_read32(); if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) { print("matrix scan frequency: "); pdec(matrix_scan_count); print("\n"); matrix_timer = timer_now; matrix_scan_count = 0; } #endif for (uint8_t i = 0; i < MATRIX_ROWS; i++) { select_row(i); wait_us(30); // without this wait read unstable value. matrix_row_t cols = read_cols(i); if (matrix_debouncing[i] != cols) { matrix_debouncing[i] = cols; if (debouncing) { debug("bounce!: "); debug_hex(debouncing); debug("\n"); } debouncing = DEBOUNCE; } unselect_rows(); } if (debouncing) { if (--debouncing) { wait_us(1); // this should be wait_ms(1) but has been left as-is at EZ's request } else { for (uint8_t i = 0; i < MATRIX_ROWS; i++) { matrix[i] = matrix_debouncing[i]; } } } matrix_scan_quantum(); return 1; }
static void refresh_commodity_register(struct commodity_register *commodity_register) { GtkTreeIter iter; GtkTreePath *path = NULL; GtkTreeModel *model = gtk_tree_view_get_model(COMMODITY_REGISTER_CORE.view); /* Is there a current selection? */ if (gtk_tree_selection_get_selected(COMMODITY_REGISTER_CORE.selection, NULL, &iter)) { /* Turn the iter into a path, since I don't think an iter can be valid after generating a new model */ path = gtk_tree_model_get_path(model, &iter); /* Generate a new model for the price register view and replace the old one */ create_commodity_register_model(commodity_register); /* Select something near the previously selected row, if there was one */ if (path != NULL) { select_row(GTK_TREE_VIEW(COMMODITY_REGISTER_CORE.view), path, VIEW_PRICE); gtk_tree_path_free(path); } } else { /* Generate a new model for the price register view and replace the old one */ create_commodity_register_model(commodity_register); /* Select the first row */ select_first_row(&(COMMODITY_REGISTER_CORE), VIEW_PRICE); gtk_tree_path_free (path); } }
const Value EngineBase::select1(const Expression &what, const Expression &from, const Expression &where) { RowPtr row = select_row(what, from, where); if (row->size() != 1) throw BadSQLOperation(_T("Unable to fetch exactly one column!")); return row->begin()->second; }
uint8_t matrix_scan(void) { for (uint8_t row = 0; row < MATRIX_ROWS; row++) { select_row(row); _delay_us(15); // without this wait it will read unstable value. 10? 50? matrix_row_t cols = read_cols(); if (cols) LedInfo1_On(); else LedInfo1_Off(); if (matrix_debouncing[row] != cols) { //dprintf("bounce %u\r\n", row); matrix_debouncing[row] = cols; debouncing_times[row] = timer_read(); debouncing[row] = true; } unselect_rows(); } for (uint8_t row = 0; row < MATRIX_ROWS; row++) { if (debouncing[row]) { LedInfo2_On(); if (timer_elapsed(debouncing_times[row]) > DEBOUNCE_TIME) { //dprintf("bounced %u\r\n", row); matrix[row] = matrix_debouncing[row]; debouncing[row] = false; send_row_to_other_side(row, matrix[row]); mcpu_send_typematrix_row(row, matrix[row]); animation_typematrix_row(row, matrix[row]); } } else { LedInfo2_Off(); } } splitbrain_communication_task(); #ifdef BACKLIGHT_ENABLE animate(); #endif return 1; }
void on_entry_changed(void) { gtk_list_store_clear(list_store); gint count = 0; GSList *i = input; for (; i != NULL && count < max_entries; i = g_slist_next(i)) if (strstr(i->data, entry_text()) != NULL) { gtk_list_store_insert_with_values(list_store, NULL, -1, 0, i->data, -1); count += 1; } select_row(0); }
uint8_t matrix_scan(void) { if (!debouncing) { uint8_t *tmp = matrix_prev; matrix_prev = matrix; matrix = tmp; } for (uint8_t i = 0; i < MATRIX_ROWS; i++) { unselect_rows(); select_row(i); _delay_us(30); // without this wait read unstable value. if ( i == ( MATRIX_ROWS - 1 ) ) { // CHECK CAPS LOCK if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { // CAPS LOCK is ON on HOST if ( ~read_col(i) & (1<< 4) ) { // CAPS LOCK is still DOWN ( 0bXXX1_XXXX) matrix[i] = ~read_col(i) & 0b11101111; // change CAPS LOCK as released } else { // CAPS LOCK in UP matrix[i] = ~read_col(i) | 0b00010000; // send fake caps lock down } } else { // CAPS LOCK is OFF on HOST if (matrix[i] != (uint8_t)~read_col(i)) { matrix[i] = (uint8_t)~read_col(i); if (debouncing) { debug("bounce!: "); debug_hex(debouncing); print("\n"); } debouncing = DEBOUNCE; } } } else { if (matrix[i] != (uint8_t)~read_col(i)) { matrix[i] = (uint8_t)~read_col(i); if (debouncing) { debug("bounce!: "); debug_hex(debouncing); print("\n"); } debouncing = DEBOUNCE; } } } unselect_rows(); if (debouncing) { debouncing--; } return 1; }
static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { // Store last value of row prior to reading matrix_row_t last_row_value = current_matrix[current_row]; // Clear data in matrix row current_matrix[current_row] = 0; // Select row and wait for row selecton to stabilize select_row(current_row); wait_us(30); current_matrix[current_row] = read_cols(); // No need to Unselect row as the next `select_row` will blank everything return (last_row_value != current_matrix[current_row]); }
uint8_t matrix_scan() { // Update LED states if necessary: #ifdef LED_CONTROLLER_ENABLE led_update(); #endif for ( uint8_t i = 0; i < MATRIX_ROWS; i++ ) { select_row( i ); _delay_us( 30 ); // without this wait read unstable value. matrix_row_t cols = read_cols(); if ( matrix_debouncing[ i ] != cols ) { matrix_debouncing[ i ] = cols; if ( debouncing ) { debug("bounce!: "); debug_hex( debouncing ); debug( "\n" ); } debouncing = DEBOUNCE; } unselect_rows(); } if ( debouncing ) { if ( --debouncing ) { _delay_ms( 1 ); } else { for ( uint8_t i = 0; i < MATRIX_ROWS; i++ ) { matrix[ i ] = matrix_debouncing[ i ]; } } } return 1; }
uint8_t matrix_scan(void) { for (uint8_t i = 0; i < MATRIX_ROWS; i++) { select_row(i); _delay_us(30); // without this wait read unstable value. matrix_row_t cols = read_cols(); if (matrix_debouncing[i] != cols) { matrix_debouncing[i] = cols; if (debouncing) { debug("bounce!: "); debug_hex(debouncing); debug("\n"); } debouncing = DEBOUNCE; } unselect_rows(); } if (debouncing) { if (--debouncing) { _delay_ms(1); } else { for (uint8_t i = 0; i < MATRIX_ROWS; i++) { matrix[i] = matrix_debouncing[i]; } } } uint8_t layer = biton32(layer_state); switch (layer) { case 1: case 2: DDRC |= (1<<7); PORTC |= (1<<7); break; case 0: DDRC &= ~(1<<7); PORTC &= ~(1<<7); break; } return 1; }
uint8_t matrix_scan(void) { #if DIODE_DIRECTION == COL2ROW for (uint8_t i = 0; i < MATRIX_ROWS; i++) { select_row(i); _delay_us(30); // without this wait read unstable value. matrix_row_t cols = read_cols(); if (matrix_debouncing[i] != cols) { matrix_debouncing[i] = cols; if (debouncing) { debug("bounce!: "); debug_hex(debouncing); debug("\n"); } debouncing = DEBOUNCE; } unselect_rows(); } if (debouncing) { if (--debouncing) { _delay_ms(1); } else { for (uint8_t i = 0; i < MATRIX_ROWS; i++) { matrix[i] = matrix_debouncing[i]; } } } #else for (uint8_t i = 0; i < MATRIX_COLS; i++) { select_row(i); _delay_us(30); // without this wait read unstable value. matrix_row_t rows = read_cols(); if (matrix_reversed_debouncing[i] != rows) { matrix_reversed_debouncing[i] = rows; if (debouncing) { debug("bounce!: "); debug_hex(debouncing); debug("\n"); } debouncing = DEBOUNCE; } unselect_rows(); } if (debouncing) { if (--debouncing) { _delay_ms(1); } else { for (uint8_t i = 0; i < MATRIX_COLS; i++) { matrix_reversed[i] = matrix_reversed_debouncing[i]; } } } for (uint8_t y = 0; y < MATRIX_ROWS; y++) { matrix_row_t row = 0; for (uint8_t x = 0; x < MATRIX_COLS; x++) { row |= ((matrix_reversed[x] & (1<<y)) >> y) << x; } matrix[y] = row; } #endif return 1; }
uint8_t matrix_scan(void) { if (mcp23018_status) { // if there was an error if (++mcp23018_reset_loop == 0) { // since mcp23018_reset_loop is 8 bit - we'll try to reset once in 255 matrix scans // this will be approx bit more frequent than once per second print("trying to reset mcp23018\n"); mcp23018_status = init_mcp23018(); if (mcp23018_status) { print("left side not responding\n"); } else { print("left side attached\n"); ergodox_blink_all_leds(); } } } #ifdef DEBUG_MATRIX_FREQ matrix_scan_count++; uint32_t timer_now = timer_read32(); if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) { print("matrix scan frequency: "); pdec(matrix_scan_count); print("\n"); matrix_timer = timer_now; matrix_scan_count = 0; } #endif #ifdef KEYMAP_CUB uint8_t layer = biton32(layer_state); ergodox_board_led_off(); ergodox_left_led_1_off(); ergodox_left_led_2_off(); ergodox_left_led_3_off(); switch (layer) { case 1: // all ergodox_left_led_1_on(); ergodox_left_led_2_on(); ergodox_left_led_3_on(); break; case 2: // blue ergodox_left_led_2_on(); break; case 8: // blue and green ergodox_left_led_2_on(); // break missed intentionally case 3: // green ergodox_left_led_3_on(); break; case 6: ergodox_board_led_on(); // break missed intentionally case 4: case 5: case 7: // red ergodox_left_led_1_on(); break; default: // none break; } mcp23018_status = ergodox_left_leds_update(); #endif #ifdef KEYMAP_SIMON uint8_t layer = biton32(layer_state); ergodox_board_led_off(); switch (layer) { case 0: // none break; default: ergodox_board_led_on(); break; } #endif for (uint8_t i = 0; i < MATRIX_ROWS; i++) { select_row(i); matrix_row_t cols = read_cols(i); if (matrix_debouncing[i] != cols) { matrix_debouncing[i] = cols; if (debouncing) { debug("bounce!: "); debug_hex(debouncing); debug("\n"); } debouncing = DEBOUNCE; } unselect_rows(); } if (debouncing) { if (--debouncing) { _delay_ms(1); } else { for (uint8_t i = 0; i < MATRIX_ROWS; i++) { matrix[i] = matrix_debouncing[i]; } } } return 1; }
bool listbox::select_row_at(const unsigned row, const bool select) { assert(generator_); return select_row(generator_->get_item_at_ordered(row), select); }
uint8_t matrix_scan(void) { #ifdef ERGODOX_LEFT_LEDS uint8_t layer = biton32(layer_state); if (layer == 1) { ergodox_left_led_1_on(); ergodox_left_led_2_off(); ergodox_left_led_3_off(); } else if (layer == 2) { ergodox_left_led_1_off(); ergodox_left_led_2_on(); ergodox_left_led_3_off(); } else if (layer == 3) { ergodox_left_led_1_off(); ergodox_left_led_2_off(); ergodox_left_led_3_on(); } else if (layer == 4) { ergodox_left_led_1_on(); ergodox_left_led_2_off(); ergodox_left_led_3_on(); } else if (layer == 5) { ergodox_left_led_1_on(); ergodox_left_led_2_on(); ergodox_left_led_3_off(); } else if (layer == 6) { ergodox_left_led_1_off(); ergodox_left_led_2_on(); ergodox_left_led_3_on(); } else if (layer == 7) { ergodox_left_led_1_on(); ergodox_left_led_2_on(); ergodox_left_led_3_on(); } else { ergodox_left_led_1_off(); ergodox_left_led_2_off(); ergodox_left_led_3_off(); } // not actually needed because we already calling init_mcp23018() in next line // ergodox_left_leds_update(); #endif uint8_t mcp23018_status = init_mcp23018(); for (uint8_t i = 0; i < MATRIX_ROWS; i++) { select_row(mcp23018_status, i); _delay_us(30); // without this wait read unstable value. matrix_row_t cols = read_cols(mcp23018_status, i); if (matrix_debouncing[i] != cols) { matrix_debouncing[i] = cols; if (debouncing) { debug("bounce!: "); debug_hex(debouncing); debug("\n"); } debouncing = DEBOUNCE; } unselect_rows(mcp23018_status); } if (debouncing) { if (--debouncing) { _delay_ms(1); } else { for (uint8_t i = 0; i < MATRIX_ROWS; i++) { matrix[i] = matrix_debouncing[i]; } } } return 1; }
uint8_t matrix_scan(void) { #ifdef DEBUG_SHOW_SCAN_LED LedInfo2_On(); #endif for (uint8_t row = 0; row < MATRIX_ROWS; row++) { select_row(row); _delay_us(15); // without this wait read unstable value. matrix_row_t cols = read_cols(); #ifndef DEBUG_SHOW_SCAN_LED if (cols) LedInfo2_On(); else LedInfo2_Off(); #endif if (matrix_debouncing[row] != cols) { // dprintf("bounce %u\r\n", row); matrix_debouncing[row] = cols; debouncing_times[row] = timer_read(); debouncing[row] = true; } unselect_rows(); } #if 0 if (debouncing) { LedInfo1_On(); if (timer_elapsed(debouncing_time) > DEBOUNCE_TIME) { for (int i = 0; i < MATRIX_ROWS; i++) { matrix[i] = matrix_debouncing[i]; } debouncing = false; } } else { LedInfo1_Off(); } #endif for (uint8_t row = 0; row < MATRIX_ROWS; row++) { if (debouncing[row]) { LedInfo1_On(); if (timer_elapsed(debouncing_times[row]) > DEBOUNCE_TIME) { // dprintf("bounced %u\r\n", row); matrix[row] = matrix_debouncing[row]; debouncing[row] = false; animation_typematrix_row(row, matrix[row]); } } else { LedInfo1_Off(); } } #ifdef BACKLIGHT_ENABLE animate(); #endif #ifdef DEBUG_SHOW_SCAN_LED LedInfo2_Off(); #endif return 1; }
//-------------------------------------------------------------- void testApp::draw(){ ofBackground(100,100,100); ofSetHexColor(0xffffff); //vidGrabber.draw(20,20); vidGrabber.update(); videoScale = 20; //cols = ofGetWidth() / videoScale; cols = camWidth / videoScale; //rows = ofGetHeight() / videoScale; rows = camHeight / videoScale; int totalPixels = camWidth*camHeight*3; //if (vidGrabber.isFrameNew()){ unsigned char * pixels = vidGrabber.getPixels(); /////// flip attempt for (int s = 0; s < 3 *camWidth; s+= 3){ for (int t = 0; t < camHeight; t++){ verticalFlip[(camHeight - t - 1) * 3 * camWidth + s] = pixels[t * 3 * camWidth + s]; verticalFlip[(camHeight - t - 1) * 3 * camWidth + s + 1] = pixels[t * 3 * camWidth + s + 1]; verticalFlip[(camHeight - t - 1) * 3 * camWidth + s + 2] = pixels[t * 3 * camWidth + s + 2]; //horizontalFlip[t * 3 * camWidth + 3 * (camWidth - 1) - s] = pixels[t * 3 * camWidth + s]; //horizontalFlip[t * 3 * camWidth + 3 * (camWidth - 1) - s + 1] = pixels[t * 3 * camWidth + s + 1]; //horizontalFlip[t * 3 * camWidth + 3 * (camWidth - 1) - s + 2] = pixels[t * 3 * camWidth + s + 2]; } } //verticalFlipTexture.loadData(verticalFlip, camWidth, camHeight, GL_RGB); //horizontalFlipTexture.loadData(horizontalFlip, camWidth, camHeight, GL_RGB); /////// end flip attept //int counter = 0; int threshold = 160; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j+=1) { if (i<16){ xPos = j*videoScale*3; yPos = i*videoScale; // int r = (yPos*camWidth*3) + xPos; // int g = (yPos*camWidth*3) + (xPos+1); // int b = (yPos*camWidth*3) + (xPos+2); // int grayPixel = (11 * pixels[r] + 16 * pixels[g] + 5 * pixels[b]) / 32; //2805 + 4080 + 1275 int loc = xPos + yPos * camWidth*3; if (verticalFlip[loc] > threshold) { // videoInverted[counter] = 255; // ofSetColor(255); dotColor = 255; pixelsB[i*j] ='1'; // whiteX = i; // whiteY = j; } else { // videoInverted[counter] = 0; // ofSetColor(0); dotColor = 0; pixelsB[i*j] ='0'; //whiteY = i; } // pixelsB[1] ='0'; //ofFill(); //ofCircle(i*20, j*20, 10, 10); //videoInverted[counter] = grayPixel; //ofCircle(whiteX, whiteY, 20, 20); //counter++; ofSetColor(dotColor); ofFill(); //ofCircle(xPos, yPos, 20, 20); ofCircle(xPos/3 +25, yPos+25, videoScale/4, videoScale/4); myfont.drawString(ofToString(pixelsB[i*j]), xPos/3+15,yPos+365); } } } //videoTexture.draw(20+camWidth,20,camWidth,camHeight); //videoTexture.loadData(videoInverted, camWidth,camHeight, GL_LUMINANCE); //////////////////// BEGIN IMPORTED LOGIC ///////////////// int i,x; int row=0; int chunk; // idle state for all lines digitalWrite(SCLK, 1); // output_high(SCLK); digitalWrite(CLK, 1); // output_high(CLK); digitalWrite(A, 0); // output_low(A); digitalWrite(B, 0); // output_low(B); digitalWrite(PIXEL, 0); // output_low(PIXEL); digitalWrite(OE, 1); // output_high(OE); // Adjust values, these values need to be 8 more to the right for (row=0;row<=3;row++) // For each of the 4 sets of lines { for (chunk=0;chunk<=16;chunk++) // Values 0 to 63 tweaked { indexes[row][chunk]=indexes[row][chunk]+8; } } //********************************************************************************************************************* for (row=0;row<=3;row++) // For each of the 4 sets of lines { // One set of 4 panels is upside down relative to the other, so half the line data needs to clock in forwards half backwards for (chunk=0;chunk<16;chunk++) // 128 chunks in the 1024 pixels we need to clock in { // imagebuf is pointer + offset extracted from array clock_pixels(pixelsB + (indexes[row][chunk]),8); } // this way round is best i think update_leds(); // Now we have 1024 pixels clocked in update the display select_row(row); // Hmmm fails if I dont do this just before clocking each 1024 pixels ... usleep(3000); } }