GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — polargraph_server_polarshield/penlift.ino at master · euphy/polargraph_server_polarshield Expand file tree/ Copy pathpenlift.inoMore file actions 94 lines (82 loc) · 2.24 KB / Copy pathpenlift.inoFile metadata and controls94 lines (82 loc) · 2.24 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 /** * Polargraph Server. - CORE * Written by Sandy Noble * Released under GNU License version 3. * http://www.polargraph.co.uk * https://github.com/euphy/polargraph_server_polarshield Penlift. This is one of the core files for the polargraph server program. This file contains the servo calls that raise or lower the pen from the page. The behaviour of the pen lift is this: If a simple "pen up", or "pen lift" command is received ("C14,END"), then the machine will not try to lift the pen if it thinks it is already up. It checks the value of the global boolean variable "isPenUp" to decide this. If a qualified "pen up" is received, that is one that includes a pen position (eg "C14,150,END"), then the global "up" position variable is updated, and the servo is moved to that position, even if it already is "up". Because naturally, if the up position has changed, even if it is already up, there's a good chance it won't be up enough. The same goes for the down. */ void penlift_movePen(int start, int end, int delay_ms) { penHeight.attach(PEN_HEIGHT_SERVO_PIN); if(start < end) { for (int i=start; i<=end; i++) { penHeight.write(i); delay(delay_ms); } } else { for (int i=start; i>=end; i--) { penHeight.write(i); delay(delay_ms); // Serial.println(i); } } penHeight.detach(); } void penlift_penUp() { if (inNoOfParams > 1) { //Serial.print("Penup with params"); int positionToMoveFrom = isPenUp ? upPosition : downPosition; upPosition = atoi(inParam1); penlift_movePen(positionToMoveFrom, upPosition, penLiftSpeed); } else { if (isPenUp == false) { penlift_movePen(downPosition, upPosition, penLiftSpeed); } } isPenUp = true; } void penlift_penDown() { // check to see if this is a multi-action command (if there's a // parameter then this sets the "down" motor position too). if (inNoOfParams > 1) { int positionToMoveFrom = isPenUp ? upPosition : downPosition; downPosition = atoi(inParam1); penlift_movePen(positionToMoveFrom, downPosition, penLiftSpeed); } else { if (isPenUp == true) { penlift_movePen(upPosition, downPosition, penLiftSpeed); } } isPenUp = false; } void penlift_testRange() { } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |