cell_reference::cell_reference(const std::string &string) { auto split = split_reference(string, absolute_column_, absolute_row_); set_column(split.first); set_row(split.second); }
protobuf::StackFrame* getProtobufStackFrame(JS::ubi::StackFrame& frame) { MOZ_ASSERT(frame, "null frames should be represented as the lack of a serialized " "stack frame"); auto id = frame.identifier(); auto protobufStackFrame = MakeUnique<protobuf::StackFrame>(); if (!protobufStackFrame) return nullptr; if (framesAlreadySerialized.has(id)) { protobufStackFrame->set_ref(id); return protobufStackFrame.release(); } auto data = MakeUnique<protobuf::StackFrame_Data>(); if (!data) return nullptr; data->set_id(id); data->set_line(frame.line()); data->set_column(frame.column()); data->set_issystem(frame.isSystem()); data->set_isselfhosted(frame.isSelfHosted()); auto source = MakeUnique<std::string>(frame.sourceLength() * sizeof(char16_t), '\0'); if (!source) return nullptr; auto buf = const_cast<char16_t*>(reinterpret_cast<const char16_t*>(source->data())); frame.source(RangedPtr<char16_t>(buf, frame.sourceLength()), frame.sourceLength()); data->set_allocated_source(source.release()); auto nameLength = frame.functionDisplayNameLength(); if (nameLength > 0) { auto functionDisplayName = MakeUnique<std::string>(nameLength * sizeof(char16_t), '\0'); if (!functionDisplayName) return nullptr; auto buf = const_cast<char16_t*>(reinterpret_cast<const char16_t*>(functionDisplayName->data())); frame.functionDisplayName(RangedPtr<char16_t>(buf, nameLength), nameLength); data->set_allocated_functiondisplayname(functionDisplayName.release()); } auto parent = frame.parent(); if (parent) { auto protobufParent = getProtobufStackFrame(parent); if (!protobufParent) return nullptr; data->set_allocated_parent(protobufParent); } protobufStackFrame->set_allocated_data(data.release()); if (!framesAlreadySerialized.put(id)) return nullptr; return protobufStackFrame.release(); }
void TransfMat3x4::toggle_finite (Proj::Axis axis) { g_return_if_fail (axis != Proj::W); if (has_finite_image(axis)) { Geom::Point dir (column(axis).affine()); Geom::Point origin (column(Proj::W).affine()); dir -= origin; set_column (axis, Proj::Pt2(dir[Geom::X], dir[Geom::Y], 0)); } else { Proj::Pt2 dir (column(axis)); Proj::Pt2 origin (column(Proj::W).affine()); dir = dir + origin; dir[2] = 1.0; set_column (axis, dir); } }
GtkWidget* setup_table(GtkTreeStore *store, const char *labelColumn[]) { GtkWidget *tree; tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); set_column(tree, labelColumn); g_object_unref (G_OBJECT (store)); g_print("setup\n"); return tree; }
// render and energize the current row, based on bitmap array void refresh_line() { int c; reset_led(); set_row(current_row); for (c=0; c<COLS; c++) if (bitmap[current_row][c]) set_column(c); /* GARY - Tuesday Sept 26 11:44pm */ need_refresh_line = 0; }
// add a column to the design // in // vals: desired values // interest: whether this column is a basis function representing neural // activation of interest // out // true if assigned // false if index out of bounds unsigned int RtDesignMatrix::addColumn(const vnl_vector<double> &vals, string name, bool interest) { unsigned int col = numAddedColumns; if (col >= columns()) { // check bounds return UINT_MAX; } // assign set_column(col, vals); columnNames[col] = name; columnOfInterestIndicator[col] = interest; numAddedColumns++; return numAddedColumns - 1; }
void maxspeed_redraw(const uint8_t force) { if (force || module_flags.maxspeed_changed) { uint16_t speed; module_flags.maxspeed_changed = false; if (maxspeed_min_difference == (uint16_t)-1) { speed = 0; } else { speed = get_average_speed(maxspeed_min_difference, WHEEL_PULSE_TABLE_SIZE - 1); } upoint_t position = {0, 5}; upoint_t glyph_size = {8, 8}; print_number(speed, position, glyph_size, 1, SPEED_DIGITS); // ugly hack to print decimal point set_column(position.x - 1 + SPEED_SIGNIFICANT_DIGITS * (glyph_size.x + 1)); send_raw_byte(0b10000000, true); } }
void avgspeed_redraw(const uint8_t force) { if (force || module_flags.avgspeed_changed) { uint16_t speed; upoint_t position = {0, 5}; upoint_t glyph_size = {8, 8}; module_flags.avgspeed_changed = false; if (avgspeed_pulses) { uint32_t time_difference = avgspeed_total_time; // speed = ((uint32_t)(((uint64_t)SPEED_FACTOR * ((avgspeed_pulses - 1))) >> FRAC_BITS)) / time_difference; speed = get_average_speed_long(time_difference, avgspeed_pulses); } else { speed = 0; } print_number(speed, position, glyph_size, 1, SPEED_DIGITS); // ugly hack to print decimal point set_column(position.x - 1 + SPEED_SIGNIFICANT_DIGITS * (glyph_size.x + 1)); send_raw_byte(0b10000000, true); } }
void config_redraw(const uint8_t force) { if (force || module_flags.config_changed) { module_flags.config_changed = false; upoint_t position = {0, 4}; upoint_t glyph_size = {8, 8}; // erase old arrows erase_module_screen(); // makes screen flicker, but this is not important - not used often print_number((uint16_t)config_pulse_distance, position, glyph_size, 1, (number_display_t) {CONFIG_DIGITS, 0}); if (config_level > 0) { position.y += 1; position.x = (CONFIG_DIGITS - config_place) * 9; set_row(position.y); set_column(position.x); char stamp = 0b111; if (config_level == 2) { stamp = 0b1; } for (uint8_t i = 0; i < 7; i++) { send_raw_byte(stamp, true); } } } }
protobuf::StackFrame* getProtobufStackFrame(JS::ubi::StackFrame& frame, size_t depth = 1) { // NB: de-duplicated string properties must be written in the same order // here as they are read in `HeapSnapshot::saveStackFrame` or else indices // in references to already serialized strings will be off. MOZ_ASSERT(frame, "null frames should be represented as the lack of a serialized " "stack frame"); auto id = frame.identifier(); auto protobufStackFrame = MakeUnique<protobuf::StackFrame>(); if (!protobufStackFrame) return nullptr; if (framesAlreadySerialized.has(id)) { protobufStackFrame->set_ref(id); return protobufStackFrame.release(); } auto data = MakeUnique<protobuf::StackFrame_Data>(); if (!data) return nullptr; data->set_id(id); data->set_line(frame.line()); data->set_column(frame.column()); data->set_issystem(frame.isSystem()); data->set_isselfhosted(frame.isSelfHosted()); auto dupeSource = TwoByteString::from(frame.source()); if (!attachTwoByteString(dupeSource, [&] (std::string* source) { data->set_allocated_source(source); }, [&] (uint64_t ref) { data->set_sourceref(ref); })) { return nullptr; } auto dupeName = TwoByteString::from(frame.functionDisplayName()); if (dupeName.isNonNull()) { if (!attachTwoByteString(dupeName, [&] (std::string* name) { data->set_allocated_functiondisplayname(name); }, [&] (uint64_t ref) { data->set_functiondisplaynameref(ref); })) { return nullptr; } } auto parent = frame.parent(); if (parent && depth < HeapSnapshot::MAX_STACK_DEPTH) { auto protobufParent = getProtobufStackFrame(parent, depth + 1); if (!protobufParent) return nullptr; data->set_allocated_parent(protobufParent); } protobufStackFrame->set_allocated_data(data.release()); if (!framesAlreadySerialized.put(id)) return nullptr; return protobufStackFrame.release(); }
/************************************************************************** Main ***************************************************************************/ int main (void) { uint8_t color = UNIQUE_COLORS -1; uint8_t row = 0; uint8_t col = 0; uint8_t quad = 0; uint8_t binary_cnt = 0; uint8_t wdt_cnt = 0; uint8_t update_cnt = 0; initialize_AVR(); SET_FLAG(SET_LEDS); chase_sequence = SMILEY; DISABLE_SERVOS(); quad_flags = 0xFF; turn_off_matrices(); // Turn On TWI TWI_RESET_WITH_ACK(); /********************************************** * MAIN LOOP * - Handle Chase Sequences **********************************************/ for(;;) { //------------------------- // Handle Color Loops //------------------------- if (FLAG_IS_SET(INCREMENT_COLOR)) { if (++color == UNIQUE_COLORS) color = 1; CLEAR_FLAG(INCREMENT_COLOR); } else if (FLAG_IS_SET(DECREMENT_COLOR)) { if (--color == 0) color = UNIQUE_COLORS -1; CLEAR_FLAG(DECREMENT_COLOR); } //------------------------- // Reset Chase Sequence //------------------------- if (FLAG_IS_SET(RESET_CHASE)) { wdt_cnt = 0; chase_sequence = LOOP_QUAD; CLEAR_FLAG(RESET_CHASE); CLEAR_FLAG(PASSIVE_MODE); ENABLE_SERVOS(); } //------------------------- // Handle Chase Sequences //------------------------- switch (chase_sequence) { //------------------------- // Constant On at the last color //------------------------- case ALL_CONSTANT: break; //------------------------- // Loop through all colors //------------------------- case LOOP_ALL: SET_FLAG(DECREMENT_COLOR); set_matrix(0, color); set_matrix(1, color); _delay_ms(100); break; //------------------------- // Color wheel - one color transistion per revolution //------------------------- case QUAD_WHEEL: if (quad == 0) { set_quadrant(0, 3, COL_BLACK); set_quadrant(1, 3, COL_BLACK); } else { set_quadrant(0, quad-1, COL_BLACK); set_quadrant(1, quad-1, COL_BLACK); } set_quadrant(0, quad, color); set_quadrant(1, quad, color); if (++quad == QUADS) { SET_FLAG(DECREMENT_COLOR); quad = 0; } _delay_ms(50); break; //------------------------- // Color wheel - change colors with quadrants //------------------------- case QUAD_WHEEL2: SET_FLAG(DECREMENT_COLOR); if (quad == 0) { set_quadrant(0, 3, COL_BLACK); set_quadrant(1, 3, COL_BLACK); } else { set_quadrant(0, quad-1, COL_BLACK); set_quadrant(1, quad-1, COL_BLACK); } set_quadrant(0, quad, color); set_quadrant(1, quad, color); if (++quad == QUADS) { quad = 0; } _delay_ms(50); break; //------------------------- // Loop through all colors in Quadrant(s) //------------------------- case LOOP_QUAD: SET_FLAG(DECREMENT_COLOR); set_quadrants(color); _delay_ms(100); break; //------------------------- // Binary Counter - by Columns //------------------------- case BINARY_COLS: for (col = 0; col < COLUMNS; ++col) { if (binary_cnt & _BV(col)) set_column(0, col, COL_BLUE); else set_column(0, col, COL_BLACK); } ++binary_cnt; _delay_ms(250); break; //------------------------- // Binary Counter - by Row //------------------------- case BINARY_ROWS: for (row = 0; row < ROWS; ++row) { if (binary_cnt & _BV(row)) set_row(0, row, COL_RED); else set_row(0, row, COL_BLACK); } ++binary_cnt; _delay_ms(250); break; //------------------------- // Display all colors //------------------------- case ALL_COLORS: if (FLAG_IS_SET(SET_LEDS)) { for (col = 0; col < COLUMNS; ++col) { for (row = 0; row < ROWS; ++row) { if (color < UNIQUE_COLORS) { set_led(0, col, row, color); ++color; } else set_led(0, col, row, COL_BLACK); } } CLEAR_FLAG(SET_LEDS); } break; //------------------------- // Smiley Faces //------------------------- case SMILEY: if (FLAG_IS_SET(SET_LEDS)) { turn_off_matrices(); // Border #define FACE_COLOR COL_OLIVE set_row(0, 0, FACE_COLOR); set_row(0, 7, FACE_COLOR); set_column(0, 0, FACE_COLOR); set_column(0, 7, FACE_COLOR); set_row(1, 0, FACE_COLOR); set_row(1, 7, FACE_COLOR); set_column(1, 0, FACE_COLOR); set_column(1, 7, FACE_COLOR); // Eyes set_led(0, 1, 1, COL_WHITE); set_led(0, 1, 2, COL_WHITE); set_led(0, 2, 1, COL_WHITE); set_led(0, 2, 2, COL_BLUE); set_led(0, 1, 5, COL_WHITE); set_led(0, 1, 6, COL_WHITE); set_led(0, 2, 5, COL_WHITE); set_led(0, 2, 6, COL_BLUE); set_led(1, 1, 1, COL_WHITE); set_led(1, 1, 2, COL_WHITE); set_led(1, 2, 2, COL_WHITE); set_led(1, 2, 1, COL_GREEN); set_led(1, 1, 5, COL_WHITE); set_led(1, 1, 6, COL_WHITE); set_led(1, 2, 6, COL_WHITE); set_led(1, 2, 5, COL_GREEN); // Nose set_led(0, 3, 4, FACE_COLOR); set_led(0, 4, 3, FACE_COLOR); set_led(0, 4, 4, FACE_COLOR); set_led(1, 3, 3, FACE_COLOR); set_led(1, 4, 3, FACE_COLOR); set_led(1, 4, 4, FACE_COLOR); // Mouth set_led(0, 5, 1, COL_CORAL); set_led(0, 6, 2, COL_CORAL); set_led(0, 6, 3, COL_CORAL); set_led(0, 6, 4, COL_CORAL); set_led(0, 6, 5, COL_CORAL); set_led(0, 5, 6, COL_CORAL); set_led(1, 5, 1, COL_CORAL); set_led(1, 6, 2, COL_CORAL); set_led(1, 6, 3, COL_CORAL); set_led(1, 6, 4, COL_CORAL); set_led(1, 6, 5, COL_CORAL); set_led(1, 5, 6, COL_CORAL); CLEAR_FLAG(SET_LEDS); SET_FLAG(UPDATE_LEDS); } // Look back and forth if (FLAG_IS_SET(UPDATE_LEDS)) { set_led(0, 2, 2, COL_WHITE); set_led(0, 2, 1, COL_BLUE); set_led(0, 2, 6, COL_WHITE); set_led(0, 2, 5, COL_BLUE); set_led(1, 2, 1, COL_WHITE); set_led(1, 2, 2, COL_GREEN); set_led(1, 2, 5, COL_WHITE); set_led(1, 2, 6, COL_GREEN); _delay_ms(200); set_led(0, 2, 1, COL_WHITE); set_led(0, 2, 2, COL_BLUE); set_led(0, 2, 5, COL_WHITE); set_led(0, 2, 6, COL_BLUE); set_led(1, 2, 2, COL_WHITE); set_led(1, 2, 1, COL_GREEN); set_led(1, 2, 6, COL_WHITE); set_led(1, 2, 5, COL_GREEN); update_cnt = SMILEY_EYE_DELAY; CLEAR_FLAG(UPDATE_LEDS); } break; //------------------------- // Set matrix to white //------------------------- case ALL_WHITE: if (FLAG_IS_SET(SET_LEDS)) { set_matrix(0, COL_WHITE); CLEAR_FLAG(SET_LEDS); } break; //------------------------- // Turn off all LEDs //------------------------- case ALL_OFF: default: if (FLAG_IS_SET(SET_LEDS)) { turn_off_matrices(); CLEAR_FLAG(SET_LEDS); } break; //------------------------- // Test - Test corner LEDs //------------------------- case TEST_CORNERS: set_led(0, 7, 0, COL_BLACK); set_led(0, 0, 0, COL_RED); set_led(0, 4, 4, COL_RED); set_led(1, 7, 7, COL_BLACK); set_led(1, 0, 7, COL_RED); set_led(1, 4, 3, COL_RED); _delay_ms(200); set_led(0, 0, 0, COL_BLACK); set_led(0, 0, 7, COL_BLUE); set_led(0, 4, 4, COL_BLUE); set_led(1, 0, 7, COL_BLACK); set_led(1, 0, 0, COL_BLUE); set_led(1, 4, 3, COL_BLUE); _delay_ms(200); set_led(0, 0, 7, COL_BLACK); set_led(0, 7, 7, COL_YELLOW); set_led(0, 4, 4, COL_YELLOW); set_led(1, 0, 0, COL_BLACK); set_led(1, 7, 0, COL_YELLOW); set_led(1, 4, 3, COL_YELLOW); _delay_ms(200); set_led(0, 7, 7, COL_BLACK); set_led(0, 7, 0, COL_GREEN); set_led(0, 4, 4, COL_GREEN); set_led(1, 7, 0, COL_BLACK); set_led(1, 7, 7, COL_GREEN); set_led(1, 4, 3, COL_GREEN); _delay_ms(200); break; } //------------------------- // Update Timer - 10ms increments //------------------------- if (update_cnt > 0) { _delay_ms(10); if (--update_cnt == 0) { SET_FLAG(UPDATE_LEDS); } } //------------------------- // WatchDog Timer //------------------------- if (wdt_cnt < WDT_MAX) { if (++wdt_cnt == WDT_MAX) { DISABLE_SERVOS(); SET_FLAG(SET_LEDS); SET_FLAG(PASSIVE_MODE); chase_sequence = SMILEY; } } } // End of Main Loop } // End of Main
int main(int argc, char **argv) { if(argc < 3) usage(); char *address = argv[1]; uint16_t port = atoi(argv[2]); int paramc = argc - 3; char **paramv = &argv[3]; if(port == 0) { printf("no valid port specified. using 0x1936.\n"); port = 0x1936; paramc++; paramv--; } int x, y, r, g, b; switch(paramv[0][0]) { case 'p': if(paramc != 6) usage(); x = atoi(paramv[1]); y = atoi(paramv[2]); r = atoi(paramv[3]); g = atoi(paramv[4]); b = atoi(paramv[5]); if( x < 0 || x > 11 || y < 0 || y > 9 || r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255 ) usage(); set_pixel(address, port, x, y, r, g, b); printf("setting pixel done\n"); break; case 'c': if(paramc != 5) usage(); x = atoi(paramv[1]); r = atoi(paramv[2]); g = atoi(paramv[3]); b = atoi(paramv[4]); if( x < 0 || x > 11 || r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255 ) usage(); set_column(address, port, x, r, g, b); printf("setting column done\n"); break; case 'f': if(paramc != 4) usage(); r = atoi(paramv[1]); g = atoi(paramv[2]); b = atoi(paramv[3]); if( r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255 ) usage(); fill(address, port, r, g, b); printf("filling done\n"); break; default: usage(); } return 0; }