void Max_LCD::noAutoscroll(void) { _displaymode &= ~LCD_ENTRYSHIFTINCREMENT; command(LCD_ENTRYMODESET | _displaymode); }
/********** high level commands, for the user! */ void LiquidCrystal_I2C::clear(){ command(LCD_CLEARDISPLAY);// clear display, set cursor position to zero delayMicroseconds(2000); // this command takes a long time! }
void LiquidCrystalKtms::clear() { command(0x20); // clear display, set cursor position to zero }
void LiquidCrystal_I2C::scrollDisplayRight(void) { command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT); }
// This is for text that flows Right to Left void LiquidCrystal_I2C::rightToLeft(void) { _displaymode &= ~LCD_ENTRYLEFT; command(LCD_ENTRYMODESET | _displaymode); }
void LiquidCrystal_I2C::display() { _displaycontrol |= LCD_DISPLAYON; command(LCD_DISPLAYCONTROL | _displaycontrol); }
void LiquidCrystal_I2C::blink() { _displaycontrol |= LCD_BLINKON; command(LCD_DISPLAYCONTROL | _displaycontrol); }
// This is for text that flows Left to Right void ControLeo_LiquidCrystal::leftToRight(void) { _displaymode |= LCD_ENTRYLEFT; command(LCD_ENTRYMODESET | _displaymode); }
// Allows us to fill the first 8 CGRAM locations // with custom characters void ControLeo_LiquidCrystal::createChar(uint8_t location, uint8_t charmap[]) { location &= 0x7; // we only have 8 locations 0-7 command(LCD_SETCGRAMADDR | (location << 3)); for (int i=0; i<8; i++) write(charmap[i]); }
// Set the cursor position to (0, 0) void ControLeo_LiquidCrystal::home() { command(LCD_RETURNHOME); // Set cursor position to zero delayMicroseconds(2000); // This command takes a long time! }
// These commands scroll the display without changing the RAM void ControLeo_LiquidCrystal::scrollDisplayLeft(void) { command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT); }
// Clear the LCD display void ControLeo_LiquidCrystal::clear() { command(LCD_CLEARDISPLAY); // Clear display, set cursor position to zero delayMicroseconds(2000); // This command takes a long time! }
/* This runs the 'file' command. */ char * do_file (const char *path) { CLEANUP_FREE char *buf = NULL; const char *display_path = path; int is_dev = STRPREFIX (path, "/dev/"); if (!is_dev) { buf = sysroot_path (path); if (!buf) { reply_with_perror ("malloc"); return NULL; } path = buf; /* For non-dev, check this is a regular file, else just return the * file type as a string (RHBZ#582484). */ struct stat statbuf; if (lstat (path, &statbuf) == -1) { reply_with_perror ("lstat: %s", display_path); return NULL; } if (! S_ISREG (statbuf.st_mode)) { char *ret; if (S_ISDIR (statbuf.st_mode)) ret = strdup ("directory"); else if (S_ISCHR (statbuf.st_mode)) ret = strdup ("character device"); else if (S_ISBLK (statbuf.st_mode)) ret = strdup ("block device"); else if (S_ISFIFO (statbuf.st_mode)) ret = strdup ("FIFO"); else if (S_ISLNK (statbuf.st_mode)) ret = strdup ("symbolic link"); else if (S_ISSOCK (statbuf.st_mode)) ret = strdup ("socket"); else ret = strdup ("unknown, not regular file"); if (ret == NULL) reply_with_perror ("strdup"); return ret; } } /* Which flags to use? For /dev paths, follow links because * /dev/VG/LV is a symbolic link. */ const char *flags = is_dev ? "-zbsL" : "-zb"; char *out; CLEANUP_FREE char *err = NULL; int r = command (&out, &err, str_file, flags, path, NULL); if (r == -1) { free (out); reply_with_error ("%s: %s", display_path, err); return NULL; } /* We need to remove the trailing \n from output of file(1). */ size_t len = strlen (out); if (len > 0 && out[len-1] == '\n') out[--len] = '\0'; /* Some upstream versions of file add a space at the end of the * output. This is fixed in the Fedora version, but we might as * well fix it here too. (RHBZ#928995). */ if (len > 0 && out[len-1] == ' ') out[--len] = '\0'; return out; /* caller frees */ }
void DOS_Shell::CMD_SUBST (char * args) { /* If more that one type can be substed think of something else * E.g. make basedir member dos_drive instead of localdrive */ HELP("SUBST"); localDrive* ldp=0; char mountstring[DOS_PATHLENGTH+CROSS_LEN+20]; char temp_str[2] = { 0,0 }; try { strcpy(mountstring,"MOUNT "); StripSpaces(args); std::string arg; CommandLine command(0,args); if (command.GetCount() != 2) throw 0 ; command.FindCommand(1,arg); if( (arg.size()>1) && arg[1] !=':') throw(0); temp_str[0]=(char)toupper(args[0]); command.FindCommand(2,arg); if((arg=="/D") || (arg=="/d")) { if(!Drives[temp_str[0]-'A'] ) throw 1; //targetdrive not in use strcat(mountstring,"-u "); strcat(mountstring,temp_str); this->ParseLine(mountstring); return; } if(Drives[temp_str[0]-'A'] ) throw 0; //targetdrive in use strcat(mountstring,temp_str); strcat(mountstring," "); Bit8u drive;char dir[DOS_PATHLENGTH+2],fulldir[DOS_PATHLENGTH]; if (strchr(arg.c_str(),'\"')==NULL) sprintf(dir,"\"%s\"",arg.c_str()); else strcpy(dir,arg.c_str()); if (!DOS_MakeName(dir,fulldir,&drive)) throw 0; if( ( ldp=dynamic_cast<localDrive*>(Drives[drive])) == 0 ) throw 0; char newname[CROSS_LEN]; strcpy(newname, ldp->basedir); strcat(newname,fulldir); CROSS_FILENAME(newname); ldp->dirCache.ExpandName(newname); strcat(mountstring,"\""); strcat(mountstring, newname); strcat(mountstring,"\""); this->ParseLine(mountstring); } catch(int a){ if(a == 0) { WriteOut(MSG_Get("SHELL_CMD_SUBST_FAILURE")); } else { WriteOut(MSG_Get("SHELL_CMD_SUBST_NO_REMOVE")); } return; } catch(...) { //dynamic cast failed =>so no localdrive WriteOut(MSG_Get("SHELL_CMD_SUBST_FAILURE")); return; } return; }
// Turn on and off the blinking cursor void LiquidCrystalRus::noBlink() { _displaycontrol &= ~LCD_BLINKON; command(LCD_DISPLAYCONTROL | _displaycontrol); }
int main (int argc, char *argv[]) { struct sockaddr_in s_in; int c; int pargc; char **pargv; while ((c = getopt (argc, argv, "Vv")) != -1) { switch (c) { case 'v': verbose = 1; break; case 'V': /* Print version and configuration to stdout and exit */ printf ("%s\n", TFTP_CONFIG_STR); exit (0); default: fprintf (stderr, "Usage: %s [-v] [host]\n", argv[0]); exit (EX_USAGE); } } pargc = argc - (optind - 1); pargv = argv + (optind - 1); sp = getservbyname ("tftp", "udp"); if (sp == 0) { /* Use canned values */ fprintf (stderr, "tftp: tftp/udp: unknown service, faking it...\n"); sp = xmalloc (sizeof (struct servent)); sp->s_name = (char *) "tftp"; sp->s_aliases = NULL; sp->s_port = htons (IPPORT_TFTP); sp->s_proto = (char *) "udp"; exit (1); } f = socket (AF_INET, SOCK_DGRAM, 0); if (f < 0) { perror ("tftp: socket"); exit (3); } bzero ((char *) &s_in, sizeof (s_in)); s_in.sin_family = AF_INET; if (bind (f, (struct sockaddr *) &s_in, sizeof (s_in)) < 0) { perror ("tftp: bind"); exit (1); } mode = MODE_DEFAULT; bsd_signal (SIGINT, intr); if (pargc > 1) { if (sigsetjmp (toplevel, 1) != 0) exit (0); setpeer (pargc, pargv); } if (sigsetjmp (toplevel, 1) != 0) (void) putchar ('\n'); #ifdef WITH_READLINE #ifdef HAVE_READLINE_HISTORY_H using_history (); #endif #endif command (); return 0; /* Never reached */ }
// This will 'right justify' text from the cursor void LiquidCrystalRus::autoscroll(void) { _displaymode |= LCD_ENTRYSHIFTINCREMENT; command(LCD_ENTRYMODESET | _displaymode); }
int main( int argc, char ** argv ) { // Checks that all required arguments are passed if( argc < 4 ) { vgLogMessage( "Missing arguments. Usage :" ); showUsage( "blowfish" /*argv[0]*/ ); return 0; } // Gets all arguments std::string command( argv[1] ); std::vector< char > key; boost::filesystem::path inPath; boost::filesystem::path outPath; key.resize( strlen(argv[2]) ); std::copy( argv[2], argv[2]+key.size(), key.begin() ); inPath = boost::filesystem::path( argv[3] ); if( !boost::filesystem::exists(inPath) ) { vgLogMessage( "Invalid input path ", inPath.string().c_str() ); return 0; } if( argc > 4 ) { outPath = boost::filesystem::path( argv[4] ); } // Process the command. if( command == "encrypt" ) { if( outPath.empty() ) { outPath = vgPhysfs::getEncryptedPath( inPath ); } std::ifstream in( inPath.string().c_str(), std::ios::binary ); std::vector< char > inBuffer; std::ofstream out( outPath.string().c_str(), std::ios::binary|std::ios::trunc ); in.seekg( 0, std::ios::end ); inBuffer.resize( in.tellg() ); in.seekg( 0, std::ios::beg ); in.read( &inBuffer[0], inBuffer.size() ); vgPhysfs::encrypt( key, inBuffer, out ); } else if( command == "decrypt" ) { if( outPath.empty() ) { outPath = inPath; if( vgPhysfs::isEncryptedPath(outPath) ) { outPath.replace_extension(); } else { outPath = outPath.string() + ".decrypted"; } } // Opens the stream and checks if it contains crypted data. std::ifstream in( inPath.string().c_str(), std::ios::binary ); if( ! vgPhysfs::isEncrypted(in) ) { vgLogMessage( "Source file does not contain valid crypted data." ); return 0; } // Decrypts and store clear data. std::vector< char > inBuffer; std::vector< char > outBuffer; if( vgPhysfs::decrypt(key, in, inBuffer, outBuffer) ) { std::ofstream out( outPath.string().c_str(), std::ios::binary|std::ios::trunc ); out.write( &outBuffer[0], outBuffer.size() ); } } else { vgLogMessage( "Unknown command." ); showUsage( "blowfish" /*argv[0]*/ ); } return 0; }
void LiquidCrystal_I2C::cursor() { _displaycontrol |= LCD_CURSORON; command(LCD_DISPLAYCONTROL | _displaycontrol); }
char *v25ter_input_encap(int c) { static char prev_cmd[CMDSIZE]; static char cmd[CMDSIZE]; static char *cmd_p; /* * A command line is made up of three elements: the prefix, the body, * and the terminate character. */ switch (state_encap) { case V25TER_STATE_NONE: /* "AT" or "at" or "A/" or "a/" */ if (toupper(c) == 'A') state_encap = V25TER_STATE_PREFIX; break; case V25TER_STATE_PREFIX: if (c == '/') { /* "A/" or "a/" */ /* Repeat the execution of the previous command line. */ state_encap = V25TER_STATE_NONE; return command(prev_cmd); } else if (toupper(c) == 'T') { /* "AT" or "at" */ cmd_p = cmd; state_encap = V25TER_STATE_BODY; } else { state_encap = V25TER_STATE_NONE; } break; case V25TER_STATE_BODY: if (c == '\r') { /* the termination character */ /* EOS */ *cmd_p = '\0'; /* Save the command line. */ strcpy(prev_cmd, cmd); /* Execute the command line. */ state_encap = V25TER_STATE_NONE; return command(cmd); } else { if (c == '\b') { /* the command line editing character */ if (cmd_p != cmd) { /* Decrement pointer. */ cmd_p--; } } else { if (cmd_p < cmd + CMDSIZE - 1) { /* Save the command character. */ *cmd_p++ = c; } } } break; default: break; } return 0; }
// These commands scroll the display without changing the RAM void LiquidCrystal_I2C::scrollDisplayLeft(void) { command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT); }
void tcGameOutcomePopup::ExitGame(wxCommandEvent& event) { wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, ID_ENDGAME); AddPendingEvent(command); }
// This is for text that flows Left to Right void LiquidCrystal_I2C::leftToRight(void) { _displaymode |= LCD_ENTRYLEFT; command(LCD_ENTRYMODESET | _displaymode); }
void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { if (lines > 1) { _displayfunction |= LCD_2LINE; } _numlines = lines; _currline = 0; // for some 1 line displays you can select a 10 pixel high font if ((dotsize != 0) && (lines == 1)) { _displayfunction |= LCD_5x10DOTS; } // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! // according to datasheet, we need at least 40ms after power rises above 2.7V // before sending commands. Arduino can turn on way before 4.5V so we'll wait 50 delayMicroseconds(50000); // Now we pull both RS and R/W low to begin commands digitalWrite(_rs_pin, LOW); digitalWrite(_enable_pin, LOW); if (_rw_pin != 255) { digitalWrite(_rw_pin, LOW); } //put the LCD into 4 bit or 8 bit mode if (! (_displayfunction & LCD_8BITMODE)) { // this is according to the Hitachi HD44780 datasheet // figure 24, pg 46 // we start in 8bit mode, try to set 4 bit mode writeNbits(0x03,4); delayMicroseconds(4500); // wait min 4.1ms // second try writeNbits(0x03,4); delayMicroseconds(4500); // wait min 4.1ms // third go! writeNbits(0x03,4); delayMicroseconds(150); // finally, set to 8-bit interface writeNbits(0x02,4); } else { // this is according to the Hitachi HD44780 datasheet // page 45 figure 23 // Send function set command sequence command(LCD_FUNCTIONSET | _displayfunction); delayMicroseconds(4500); // wait more than 4.1ms // second try command(LCD_FUNCTIONSET | _displayfunction); delayMicroseconds(150); // third go command(LCD_FUNCTIONSET | _displayfunction); } // finally, set # lines, font size, etc. command(LCD_FUNCTIONSET | _displayfunction); // turn the display on with no cursor or blinking default _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; display(); // clear it off clear(); // Initialize to default text direction (for romance languages) _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; // set the entry mode command(LCD_ENTRYMODESET | _displaymode); }
// This will 'left justify' text from the cursor void LiquidCrystal_I2C::noAutoscroll(void) { _displaymode &= ~LCD_ENTRYSHIFTINCREMENT; command(LCD_ENTRYMODESET | _displaymode); }
// Turn the display on/off (quickly) void LiquidCrystalRus::noDisplay() { _displaycontrol &= ~LCD_DISPLAYON; command(LCD_DISPLAYCONTROL | _displaycontrol); }
void LiquidCrystal_I2C::home(){ command(LCD_RETURNHOME); // set cursor position to zero delayMicroseconds(2000); // this command takes a long time! }
// Turns the underline cursor on/off void LiquidCrystalRus::noCursor() { _displaycontrol &= ~LCD_CURSORON; command(LCD_DISPLAYCONTROL | _displaycontrol); }
void LiquidCrystalKtms::setCursor(uint8_t col, uint8_t row) { command ( 0xe0 | (col & 0x1f) ); }
void Max_LCD::rightToLeft(void) { _displaymode &= ~LCD_ENTRYLEFT; command(LCD_ENTRYMODESET | _displaymode); }