bool StartupScreen::onMessage(uint16_t cmd, uint8_t len, byte* buffer) { switch(cmd) { case SerialComponent::msg_base_hello: set_line(1, "Waiting for Laser..."); red_led.on(); base.send_message(SerialComponent::msg_lid_hello); // TODO : make this depend on disk state if that ever works base.send_message(SerialComponent::msg_lid_ready); return true; case SerialComponent::msg_laser_seen: yellow_led.on(); set_line(1, " Laser Detected "); return true; case SerialComponent::msg_laser_ready: green_led.on(); set_line(1, " Laser Ready "); delay(1000); return true; case SerialComponent::msg_base_ready: // set_line(1, "Next Screen..."); delay(500); g_controller.setScreen(g_ready_screen); return true; } return false; }
void ReadyScreen::onEnter() { set_line(1, s(S_RUMBLE)); set_line(2, s(S_BLANK)); set_line(3, s(S_BLANK)); onLaserOn(); red_led.on(); yellow_led.off(); green_led.off(); go_button_led.off(); }
void main_menu:: draw_three_lines(double x0, double y0, double z0, double x00, double y00, double z00) { double xx1 = m_project->get_x_projection(x0, y0, z0); double yy1 = m_project->get_y_projection(x0, y0, z0); double xx2 = m_project->get_x_projection(x0, y00, z0); double yy2 = m_project->get_y_projection(x0, y00, z0); double xx3 = m_project->get_x_projection(x00, y0, z00); double yy3 = m_project->get_y_projection(x00, y0, z00); double xx4 = m_project->get_x_projection(x00, y00, z00); double yy4 = m_project->get_y_projection(x00, y00, z00); set_line(xx1, yy1, xx2, yy2); set_line(xx2, yy2, xx4, yy4); set_line(xx1, yy1, xx3, yy3); }
static int read_buffer(const int fd, char **line) { static char *(keep[1024]) = {0}; char *buf; int len; t_gnl g; g.fd = fd; g.buffer = keep[fd]; buf = ft_strnew((keep[fd]) ? ft_strlen(keep[fd]) : BUFF_SIZE); if ((buf = stop(&g, buf, &len)) == NULL) return (-2); *line = ft_strnew(len); if (keep[fd]) ft_memdel((void**)&keep[fd]); keep[fd] = ft_strnew(len); keep[fd] = ft_strcpy(keep[fd], set_line(buf, *line, len)); if (!*buf) { if (keep[fd]) ft_memdel((void**)&keep[fd]); ft_memdel((void**)&buf); return (-1); } ft_memdel((void**)&buf); return (len); }
void image_base::clear() { boost::shared_array<color> line(new color[get_width()]); ::memset(line.get(), 0x0, get_width() * sizeof(color)); for (pos_t y = 0; y < get_height(); y++) set_line(y, 0, get_width(), line.get()); }
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 where_is (char * name) { struct line seqname; int vec; int code; struct cmd_func * cmd; if (!find_function (&vec, &cmd, name, strlen(name))) code = cmd - the_funcs[vec]; else if (map_id (name) >= 0) { code = map_id (name); vec = -1; } else io_error_msg ("%s is not a function.", name); /* no return */ code = cmd - the_funcs[vec]; init_line (&seqname); set_line (&seqname, ""); if (!search_map_for_cmd (&seqname, the_cmd_frame->top_keymap, vec, code)) io_info_msg ("%s is not on any keys.", name); else io_info_msg ("%s is bound to %s.", name, seqname.buf); free_line (&seqname); }
void cococart_slot_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { switch(id) { case TIMER_CART: set_line("CART", m_cart_line, (cococart_line_value) param); break; case TIMER_NMI: set_line("NMI", m_nmi_line, (cococart_line_value) param); break; case TIMER_HALT: set_line("HALT", m_halt_line, (cococart_line_value) param); break; } }
void stop_playback(Context *c) { for (int line = 0; line < c->num_lines; line++) { set_line(c, line, 1, 0.0f); } for (int line = 0; line < c->num_lines; line++) { Pa_CloseStream(c->streams[line]); } }
void StartupScreen::onEnter() { _lcd->clear(); _lcd->setCursor(0, 0); red_led.off(); yellow_led.off(); green_led.off(); go_button_led.off(); _lcd->print(s(S_SCOOTERBOT)); set_line(1, s(S_CONNECTING)); }
bool CountdownScreen::onMessage(uint16_t cmd, uint8_t len, byte* buffer) { char* n = ""; NUM++; //char b[22]; //snprintf(b,22,"0x%02x (%03d): %06d", cmd, cmd, NUM); //_lcd->setCursor(0, 3); //_lcd->print(b); switch(cmd) { case SerialComponent::msg_count_4: _n = 1; n = "4"; red_led.setFadeDown(255, 950); yellow_led.setFadeDown(255, 950); break; case SerialComponent::msg_count_3: _n = 2; red_led.setFadeDown(255, 950); yellow_led.setFadeDown(255, 950); n = "3"; break; case SerialComponent::msg_count_2: _n = 3; n = "2"; yellow_led.setFadeDown(255, 950); break; case SerialComponent::msg_count_1: _n = 4; n = "1"; yellow_led.on(); break; case SerialComponent::msg_go: g_controller.setScreen(g_timing_screen); set_line(2, s(S_GO)); yellow_led.off(); green_led.on(); return true; case SerialComponent::msg_jump_start: g_controller.onFoul(s(S_FALSE_START)); return true; default: return false; } // finish dots _lcd->setCursor((_n - 1) * 4 + _ndots, 2); while(_ndots < 4) { _ndots++; _lcd->print("."); } int pos = _n * 4; _ndots = 0; _dot_start = millis(); _lcd->setCursor(pos, 2); _lcd->print(n); return true; }
Variant IncOpExpression::evalUncommon( LvalExpression *lval, Variant &left, CVarRef right, bool inc, const Location &self, const Location *other) { if (RuntimeOption::EnableStrict) { if (!VariableExpression::CheckCompatibleAssignment(left, right)) { // inline SET_LINE if (!set_line(self.line0, self.char0, self.line1, self.char1)) { return Variant::lvalBlackHole(); } throw_strict(TypeVariableChangeException( location_to_string(other)), StrictMode::StrictHardCore); } } // inline SET_LINE if (!set_line(self.line0, self.char0, self.line1, self.char1)) { return Variant::lvalBlackHole(); } return lval->setOpVariant(left, inc ? (int)T_INC : (int)T_DEC, right); }
int main(int argc, char** argv) { char line[LINE_BUF_SIZE]; double value; while(fgets(line, LINE_BUF_SIZE, stdin) != NULL) { set_line(line); value = parse_line(); printf(">>%f\n", value); } return 0; }
int get_next_line(int fd, char **line) { t_fd *fd_list; char *buff; char *tmp; int size; size = 0; if (!(fd_list = get_fd(fd)) || !line || fd < 0) return (-1); if (!(buff = (char*)malloc(BUFF_SIZE))) return (-1); tmp = (fd_list->current ? ft_strchr(fd_list->current, '\n') : NULL); if (tmp) return (set_line(line, fd_list, tmp)); if ((size = (int)read(fd, buff, BUFF_SIZE)) <= 0) return (!*(fd_list->current) ? size : set_line(line, fd_list, tmp)); if (size > 0) set_fd(size, buff, fd_list); return (get_next_line(fd, line)); }
int main() { LINE_LIST *ll = //set_line("#define ssss(asdf, abcf) abd##tfs ## abcf##dc abcf\\"); set_line("#define ssss(asdf, abcf) abcf\\"); put_line(ll, "asdf##crt"); put_line(ll, "#define rollrat rollratset"); DEF_LIST *dl = parse_define(ll); char buf[999]; replace_defines(dl, "asdxc ssss(crt, (s,t))asdf rollrat()", buf); printf(buf); }
void print_text_column(Context *c, const char *column, int num_rows) { int lines_per_pixel = c->num_lines / num_rows; for (int row = 0; row < num_rows; row++) { int line_offset = row * lines_per_pixel; char letter = column[row]; for (int line = line_offset; line < line_offset+lines_per_pixel; line++) { set_line(c, line, letter == '#' ? 0 : 1, 1.0f); } } usleep(c->msec_per_col * 1000); }
void cmd_set(Ttoken *t) { char *name; int x; int y; int dir = NO_CHANGE; name = t->word; t = (Ttoken *)t->next; if (!strncmp(name, "line", 4)) { // special handling of lines Tscript_object *s, *d; int sx, sy, dx, dy; if (t == NULL) return; s = get_object(t->word); if (s == NULL) return; t = (Ttoken *)t->next; if (t == NULL) return; sx = atoi(t->word); t = (Ttoken *)t->next; if (t == NULL) return; sy = atoi(t->word); t = (Ttoken *)t->next; if (t == NULL) return; d = get_object(t->word); if (d == NULL) return; t = (Ttoken *)t->next; if (t == NULL) return; dx = atoi(t->word); t = (Ttoken *)t->next; if (t == NULL) return; dy = atoi(t->word); set_line(name, s, sx, sy, d, dx, dy); } else { if (t->word[0] == '*') x = NO_CHANGE; else x = atoi(t->word); t = (Ttoken *)t->next; if (t->word[0] == '*') y = NO_CHANGE; else y = atoi(t->word); t = (Ttoken *)t->next; if (t != NULL) { if (!stricmp(t->word, "right")) dir = 1; else if (!stricmp(t->word, "rotate")) dir = 2; else dir = 0; } set_object(name, x, y, dir); } }
void print_image_column(Context *c, const char *column, int num_rows, float max) { int lines_per_pixel = c->num_lines / num_rows; for (int row = 0; row < num_rows; row++) { int line_offset = row * lines_per_pixel; char val = column[row]; float intensity = (float)val/max; for (int line = line_offset; line < line_offset+lines_per_pixel; line++) { set_line(c, line, 0, intensity); } } usleep(c->msec_per_col * 1000); }
static void history_up(t_tokenline *tl) { int entry; if (tl->hist_step == -1) entry = history_previous(tl, tl->hist_end); else entry = history_previous(tl, tl->hist_step); if (entry == -1) return; line_clear(tl); set_line(tl, tl->hist_buf + entry); tl->hist_step = entry; }
void parse_line(char *buf) { Token token; set_line(buf); for (;;) { get_token(&token); if (token.kind == END_OF_LINE_TOKEN) { printf("end of the world\n"); break; } else printf("kind: %d, str: %s\n", token.kind, token.str); } }
int main(int argc, const char *argv[]) { char line[LINE_BUF_SIZE]; double value; Token *test; while(fgets(line,LINE_BUF_SIZE,stdin) != NULL) { set_line(line); //get_token(test); //printf("%lf",test->value); value=parse_line(); printf("%f\n",value); //printf("hello world !\n"); } return 0; }
int main(int argc, char* argv[]) { double value; char buf[1024] = {0}; extern double parse_line(void); while (NULL != fgets(buf, 1024, stdin)) { set_line(buf); value = parse_line(); fprintf(stdout, ">> %lf\n", value); } return 0; }
/* ここから下はテストドライバ*/ void parse_line(char *buf) { Token token; set_line(buf); for(;;) { get_token(&token); if (token.kind == END_OF_LINE_TOKEN) { break; } else { printf("kind..%d, star..%s\n", token.kind, token.str); } } }
void set_speed(void) { const char *s, *errstr; int speed; s = get_input("New speed?"); if (s == NULL || *s == '\0') return; speed = strtonum(s, 0, UINT_MAX, &errstr); if (errstr != NULL) { cu_warnx("speed is %s: %s", errstr, s); return; } if (set_line(speed) != 0) cu_warn("tcsetattr"); }
void seqdata::draw_line_on_window () { m_gc->set_foreground(black_paint()); set_line(Gdk::LINE_SOLID); draw_drawable /* replace old */ ( m_old.x, m_old.y, m_old.x, m_old.y, m_old.width + 1, m_old.height + 1 ); int x, y, w, h; xy_to_rect(m_drop_x, m_drop_y, m_current_x, m_current_y, x, y, w, h); x -= m_scroll_offset_x; m_old.x = x; m_old.y = y; m_old.width = w; m_old.height = h; draw_line ( black_paint(), m_current_x - m_scroll_offset_x, m_current_y, m_drop_x - m_scroll_offset_x, m_drop_y ); }
static void history_down(t_tokenline *tl) { int i; if (tl->hist_step == -1) return; line_clear(tl); if (tl->hist_step == tl->hist_end) { tl->hist_step = -1; return; } i = tl->hist_step; while (tl->hist_buf[i]) { if (++i == TL_MAX_HISTORY_SIZE) i = 0; } if (++i == TL_MAX_HISTORY_SIZE) i = 0; set_line(tl, tl->hist_buf + i); tl->hist_step = i; }
void seqdata::draw_events_on (Glib::RefPtr<Gdk::Drawable> drawable) { midipulse tick; midibyte d0, d1; bool selected; int starttick = m_scroll_offset_ticks; int endtick = (m_window_x * m_zoom) + m_scroll_offset_ticks; draw_rectangle(drawable, white_paint(), 0, 0, m_window_x, m_window_y); m_gc->set_foreground(black_paint()); #ifdef USE_STAZED_SEQDATA_EXTENSIONS int numselected = EVENTS_ALL; // -1 int seltype = numselected; if (m_status == EVENT_NOTE_ON) // ??????? iffy. { numselected = m_seq.get_num_selected_events(m_status, m_cc); if (numselected > 0) seltype = EVENTS_UNSELECTED; } do { #endif m_seq.reset_draw_marker(); #ifdef USE_STAZED_SEQDATA_EXTENSIONS while ( m_seq.get_next_event(m_status, m_cc, &tick, &d0, &d1, &selected, seltype) ) #else while (m_seq.get_next_event(m_status, m_cc, &tick, &d0, &d1, &selected)) #endif { if (tick >= starttick && tick <= endtick) { int event_x = tick / m_zoom; /* screen coordinate */ int event_height = event::is_one_byte_msg(m_status) ? d0 : d1 ; int x = event_x - m_scroll_offset_x + 1; set_line(Gdk::LINE_SOLID, 2); /* vertical event line */ draw_line ( drawable, selected ? dark_orange() : black_paint(), x, c_dataarea_y - event_height, x, c_dataarea_y ); #ifdef USE_STAZED_SEQDATA_EXTENSIONS draw_rectangle /* draw handle */ ( drawable, selected ? dark_orange() : black_paint(), // true, event_x - m_scroll_offset_x - 3, c_dataarea_y - event_height, c_data_handle_x, c_data_handle_y ); #endif drawable->draw_drawable ( m_gc, m_numbers[event_height], 0, 0, x + 2, c_dataarea_y - m_number_h + 3, m_number_w, m_number_h ); } } #ifdef USE_STAZED_SEQDATA_EXTENSIONS if (seltype == EVENTS_UNSELECTED) seltype = numselected; else break; } while (seltype == EVENTS_UNSELECTED); #endif }
void main_menu:: draw_A() { double x1 = 0; double y1 = 300; double z1 = 0; double x2 = 0; double y2 = 900; double z2 = 0; double x3 = 150; double y3 = 600; double z3 = 150; double x4 = 150; double y4 = 600; double z4 = -150; double x5 = -150; double y5 = 600; double z5 = 150; double x6 = -150; double y6 = 600; double z6 = -150; double xx1 = m_project->get_x_projection(x1, y1, z1); double xx2 = m_project->get_x_projection(x2, y2, z2); double xx3 = m_project->get_x_projection(x3, y3, z3); double xx4 = m_project->get_x_projection(x4, y4, z4); double xx5 = m_project->get_x_projection(x5, y5, z5); double xx6 = m_project->get_x_projection(x6, y6, z6); double yy1 = m_project->get_y_projection(x1, y1, z1); double yy2 = m_project->get_y_projection(x2, y2, z2); double yy3 = m_project->get_y_projection(x3, y3, z3); double yy4 = m_project->get_y_projection(x4, y4, z4); double yy5 = m_project->get_y_projection(x5, y5, z5); double yy6 = m_project->get_y_projection(x6, y6, z6); set_line(xx1, yy1, xx3, yy3); set_line(xx1, yy1, xx4, yy4); set_line(xx1, yy1, xx5, yy5); set_line(xx1, yy1, xx6, yy6); set_line(xx2, yy2, xx3, yy3); set_line(xx2, yy2, xx4, yy4); set_line(xx2, yy2, xx5, yy5); set_line(xx2, yy2, xx6, yy6); set_line(xx3, yy3, xx4, yy4); set_line(xx6, yy6, xx4, yy4); set_line(xx5, yy5, xx6, yy6); set_line(xx3, yy3, xx5, yy5); }
int main(){ int i, tmp; tree_node *txt1, *txt2, *txt3; char *c; printf("starting \n"); txt1 = create_text(); txt2 = create_text(); txt3 = create_text(); append_line(txt1, "line one" ); if( (tmp = length_text(txt1)) != 1) { printf("Test 1: length should be 1, is %d\n", tmp); exit(-1); } append_line(txt1, "line hundred" ); insert_line(txt1, 2, "line ninetynine" ); insert_line(txt1, 2, "line ninetyeight" ); insert_line(txt1, 2, "line ninetyseven" ); insert_line(txt1, 2, "line ninetysix" ); insert_line(txt1, 2, "line ninetyfive" ); for( i = 2; i <95; i++ ) insert_line(txt1, 2, "some filler line between 1 and 95" ); if( (tmp = length_text(txt1)) != 100) { printf("Test 2: length should be 100, is %d\n", tmp); exit(-1); } printf("found at line 1: %s\n",get_line(txt1, 1)); printf("found at line 2: %s\n",get_line(txt1, 2)); printf("found at line 99: %s\n",get_line(txt1, 99)); printf("found at line 100: %s\n",get_line(txt1,100)); for(i=1; i<=10000; i++) { if( i%2==1 ) append_line(txt2, "A"); else append_line(txt2, "B"); } if( (tmp = length_text(txt2)) != 10000) { printf("Test 3: length should be 10000, is %d\n", tmp); exit(-1); } c = get_line(txt2, 9876 ); if( *c != 'B') { printf("Test 4: line 9876 of txt2 should be B, found %s\n", c); exit(-1); } for( i= 10000; i > 1; i-=2 ) { c = delete_line(txt2, i); if( *c != 'B') { printf("Test 5: line %d of txt2 should be B, found %s\n", i, c); exit(-1); } append_line( txt2, c ); } for( i=1; i<= 5000; i++ ) { c = get_line(txt2, i); if( *c != 'A') { printf("Test 6: line %d of txt2 should be A, found %s\n", i, c); exit(-1); } } for( i=1; i<= 5000; i++ ) delete_line(txt2, 1 ); for( i=1; i<= 5000; i++ ) { c = get_line(txt2, i); if( *c != 'B') { printf("Test 7: line %d of txt2 should be B, found %s\n", i, c); exit(-1); } } set_line(txt1, 100, "the last line"); for( i=99; i>=1; i-- ) delete_line(txt1, i ); printf("found at the last line: %s\n",get_line(txt1, 1)); for(i=0; i<1000000; i++) append_line(txt3, "line" ); if( (tmp = length_text(txt3)) != 1000000) { printf("Test 8: length should be 1000000, is %d\n", tmp); exit(-1); } for(i=0; i<500000; i++) delete_line(txt3, 400000 ); if( (tmp = length_text(txt3)) != 500000) { printf("Test 9: length should be 500000, is %d\n", tmp); exit(-1); } printf("End of tests\n"); return 0; }
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(); }