void pe_set_solenoid(const uint8_t extruder_num, const uint8_t state) { switch (extruder_num) { case 1: OUT_WRITE(SOL1_PIN, state); break; default: OUT_WRITE(SOL0_PIN, state); break; } #if PARKING_EXTRUDER_SOLENOIDS_DELAY > 0 gcode.dwell(PARKING_EXTRUDER_SOLENOIDS_DELAY); #endif }
void Laser::Init() { // Initialize timers for laser intensity control #if LASER_CONTROL == 1 #if IS_TIMER_3_PWR timer3_init(LASER_PWR_PIN); #elif IS_TIMER_4_PWR timer4_init(LASER_PWR_PIN); #endif #elif LASER_CONTROL == 2 #if IS_TIMER_3_PWM timer3_init(LASER_PWM_PIN); #elif IS_TIMER_4_PWM timer4_init(LASER_PWM_PIN); #endif #endif #if ENABLED(LASER_PERIPHERALS) OUT_WRITE(LASER_PERIPHERALS_PIN, HIGH); // Laser peripherals are active LOW, so preset the pin OUT_WRITE(LASER_PERIPHERALS_STATUS_PIN, HIGH); // Set the peripherals status pin to pull-up. #endif #if LASER_CONTROL == 2 OUT_WRITE(LASER_PWR_PIN, LASER_UNARM); // Laser FIRING is active LOW, so preset the pin #endif // initialize state to some sane defaults laser.intensity = 100.0; laser.ppm = 0.0; laser.duration = 0; laser.status = LASER_OFF; laser.firing = LASER_ON; laser.mode = CONTINUOUS; laser.last_firing = 0; laser.diagnostics = false; laser.time = 0; #if ENABLED(LASER_RASTER) laser.raster_aspect_ratio = LASER_RASTER_ASPECT_RATIO; laser.raster_mm_per_pulse = LASER_RASTER_MM_PER_PULSE; laser.raster_direction = 1; #endif // LASER_RASTER laser.extinguish(); }
/** * M80 : Turn on the Power Supply * M80 S : Report the current state and exit */ void GcodeSuite::M80() { // S: Report the current power supply state and exit if (parser.seen('S')) { serialprintPGM(powersupply_on ? PSTR("PS:1\n") : PSTR("PS:0\n")); return; } PSU_ON(); /** * If you have a switch on suicide pin, this is useful * if you want to start another print with suicide feature after * a print without suicide... */ #if HAS_SUICIDE OUT_WRITE(SUICIDE_PIN, HIGH); #endif #if DISABLED(AUTO_POWER_CONTROL) delay(100); // Wait for power to settle restore_stepper_drivers(); #endif #if HAS_LCD_MENU ui.reset_status(); #endif }
// HAL initialization task void HAL_init(void) { // Initialize the USB stack #if ENABLED(SDSUPPORT) OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up #endif usb_task_init(); }
int dac_init() { #if PIN_EXISTS(DAC_DISABLE) OUT_WRITE(DAC_DISABLE_PIN, LOW); // set pin low to enable DAC #endif mcp4728_init(); if (mcp4728_simpleCommand(RESET)) return -1; dac_present = true; mcp4728_setVref_all(DAC_STEPPER_VREF); mcp4728_setGain_all(DAC_STEPPER_GAIN); return 0; }
CardReader::CardReader() { filesize = 0; sdpos = 0; sdprinting = false; cardOK = false; saving = false; logging = false; workDirDepth = 0; file_subcall_ctr = 0; memset(workDirParents, 0, sizeof(workDirParents)); autostart_stilltocheck = true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software. autostart_index = 0; //power to SD reader #if SDPOWER > -1 OUT_WRITE(SDPOWER, HIGH); #endif //SDPOWER next_autostart_ms = millis() + 5000; }
int dac_init() { #if PIN_EXISTS(DAC_DISABLE) OUT_WRITE(DAC_DISABLE_PIN, LOW); // set pin low to enable DAC #endif mcp4728_init(); if (mcp4728_simpleCommand(RESET)) return -1; dac_present = true; mcp4728_setVref_all(DAC_STEPPER_VREF); mcp4728_setGain_all(DAC_STEPPER_GAIN); if (mcp4728_getDrvPct(0) < 1 || mcp4728_getDrvPct(1) < 1 || mcp4728_getDrvPct(2) < 1 || mcp4728_getDrvPct(3) < 1 ) { mcp4728_setDrvPct(dac_channel_pct); mcp4728_eepromWrite(); } return 0; }
uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) { uint8_t i, y; switch (msg) { case U8G_DEV_MSG_INIT: { OUT_WRITE(ST7920_CS_PIN, LOW); OUT_WRITE(ST7920_DAT_PIN, LOW); OUT_WRITE(ST7920_CLK_PIN, HIGH); ST7920_CS(); u8g_Delay(120); //initial delay for boot up ST7920_SET_CMD(); ST7920_WRITE_BYTE(0x20); //non-extended mode ST7920_WRITE_BYTE(0x08); //display off, cursor+blink off ST7920_WRITE_BYTE(0x01); //clear DDRAM ram u8g_Delay(15); //delay for DDRAM clear ST7920_WRITE_BYTE(0x24); //extended mode ST7920_WRITE_BYTE(0x26); //extended mode + GDRAM active for (y = 0; y < (LCD_PIXEL_HEIGHT) / 2; y++) { //clear GDRAM ST7920_WRITE_BYTE(0x80 | y); //set y ST7920_WRITE_BYTE(0x80); //set x = 0 ST7920_SET_DAT(); for (i = 0; i < 2 * (LCD_PIXEL_WIDTH) / 8; i++) //2x width clears both segments ST7920_WRITE_BYTE(0); ST7920_SET_CMD(); } ST7920_WRITE_BYTE(0x0C); //display on, cursor+blink off ST7920_NCS(); } break; case U8G_DEV_MSG_STOP: break; case U8G_DEV_MSG_PAGE_NEXT: { uint8_t* ptr; u8g_pb_t* pb = (u8g_pb_t*)(dev->dev_mem); y = pb->p.page_y0; ptr = (uint8_t*)pb->buf; ST7920_CS(); for (i = 0; i < PAGE_HEIGHT; i ++) { ST7920_SET_CMD(); if (y < 32) { ST7920_WRITE_BYTE(0x80 | y); //y ST7920_WRITE_BYTE(0x80); //x=0 } else { ST7920_WRITE_BYTE(0x80 | (y - 32)); //y ST7920_WRITE_BYTE(0x80 | 8); //x=64 } ST7920_SET_DAT(); ST7920_WRITE_BYTES(ptr, (LCD_PIXEL_WIDTH) / 8); //ptr is incremented inside of macro y++; } ST7920_NCS(); } break; } #if PAGE_HEIGHT == 8 return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg); #elif PAGE_HEIGHT == 16 return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg); #else return u8g_dev_pb32h1_base_fn(u8g, dev, msg, arg); #endif }