uint16_t picaso4d::txt_FontSD(uint8_t fontNumber) { if (fontNumber >= PICASO_NUM_FONTS) return 0; writeWord(0xFFE5); writeWord(_fontHandles[fontNumber]); return getACKresponse(); }
/********************************************************************* * @fn writeItem * * @brief Write a data item to NV. Function can write an entire item to NV * * @param pg - Page number * @param offset - offset within the NV page where to write the new item * @param id - NV item ID * @param alignedLen - Length of data to write, alinged in flash word * boundary * @param *pBuf - Data to write. * * @return none */ static void writeItem( uint8 pg, uint16 offset, osalSnvId_t id, uint16 alignedLen, uint8 *pBuf ) { osalNvItemHdr_t hdr; hdr.id = 0xFFFF; hdr.len = alignedLen | OSAL_NV_INVALID_LEN_MARK; // Write the len portion of the header first writeWord(pg, offset + alignedLen, (uint8 *) &hdr); // remove invalid len mark hdr.len &= ~OSAL_NV_INVALID_LEN_MARK; writeWord(pg, offset + alignedLen, (uint8 *) &hdr); // Copy over the data writeWordM(pg, offset, pBuf, alignedLen / OSAL_NV_WORD_SIZE); // value is valid. Write header except for the most significant bit. hdr.id = id | OSAL_NV_INVALID_ID_MARK; writeWord(pg, offset + alignedLen, (uint8 *) &hdr); // write the most significant bit hdr.id &= ~OSAL_NV_INVALID_ID_MARK; writeWord(pg, offset + alignedLen, (uint8 *) &hdr); }
void picaso4d::gfx_PutPixel(uint16_t x, uint16_t y, uint16_t color) { writeWord(0xFFC1); writeWord(x); writeWord(y); writeWord(color); getACK(); }
void SX1509::writePin(byte pin, byte highLow) { unsigned int tempRegDir = readWord(REG_DIR_B); if ((0xFFFF^tempRegDir)&(1<<pin)) // If the pin is an output, write high/low { unsigned int tempRegData = readWord(REG_DATA_B); if (highLow) tempRegData |= (1<<pin); else tempRegData &= ~(1<<pin); writeWord(REG_DATA_B, tempRegData); } else // Otherwise the pin is an input, pull-up/down { unsigned int tempPullUp = readWord(REG_PULL_UP_B); unsigned int tempPullDown = readWord(REG_PULL_DOWN_B); if (highLow) // if HIGH, do pull-up, disable pull-down { tempPullUp |= (1<<pin); tempPullDown &= ~(1<<pin); writeWord(REG_PULL_UP_B, tempPullUp); writeWord(REG_PULL_DOWN_B, tempPullDown); } else // If LOW do pull-down, disable pull-up { tempPullDown |= (1<<pin); tempPullUp &= ~(1<<pin); writeWord(REG_PULL_UP_B, tempPullUp); writeWord(REG_PULL_DOWN_B, tempPullDown); } } }
void picaso4d::gfx_ClipWindow(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { writeWord(0xFFB5); writeWord(x1); writeWord(y1); writeWord(x2); writeWord(y2); getACK(); }
void initDisplay() { // All digits on writeWord(0x0b07); // Set maximum brightness writeWord(0x0a0f); // Turn it on writeWord(0x0c01); }
void picaso4d::gfx_Circle(uint16_t x, uint16_t y, uint16_t rad, uint16_t color) { writeWord(0xFFC3); writeWord(x); writeWord(y); writeWord(rad); writeWord(color); getACK(); }
uint16_t picaso4d::img_SetWord(uint16_t handle, uint16_t index, uint16_t offset, uint16_t value) { writeWord(0xFF49); writeWord(handle); writeWord(index); writeWord(offset); writeWord(value); return getACKresponse(); }
void picaso4d::touch_DetectRegion(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { writeWord(0xFF39); writeWord(x1); writeWord(y1); writeWord(x2); writeWord(y2); getACK(); }
void BitmapWriter::writeFileHeader(struct fileheader & fileheader, FILE * file) { writeWord(fileheader.type, file); writeDWord(fileheader.fileSize, file); writeWord(fileheader.reserved1, file); writeWord(fileheader.reserved2, file); writeDWord(fileheader.offset, file); }
/*-------------------------------------------------------------- * Save a graph on a file readable by a BinaryGraphLoader. * NOTE: the output stream must be open with the * ios::binary | ios::out mode. -------------------------------------------------------------*/ void BinaryGraphLoader::write(ostream& out, Graph &g) { int i,j; writeWord(out, g.NodeCount()); for(i=0; i<g.NodeCount(); i++) { writeWord(out, g.OutEdgeCount(i)); for(j=0; j<g.OutEdgeCount(i); j++) writeWord(out, g.GetOutEdge(i,j,NULL)); } }
uint16_t picaso4d::fileLoadImageControl(const char * datFilename, const char * gciFilename, uint16_t mode) { writeWord(0x0009); DISPLAY_SERIAL.print(datFilename); DISPLAY_SERIAL.write(0x00); //send null terminator DISPLAY_SERIAL.print(gciFilename); DISPLAY_SERIAL.write(0x00); //send null terminator (print does not include the null, uses strlen() to calculate num chars) writeWord(mode); return getACKresponse(); }
void picaso4d::gfx_Polyline(uint16_t n, uint16_t * xvalues, uint16_t * yvalues, uint16_t color) { writeWord(0x0015); writeWord(n); for (int i = 0; i < n; i++) writeWord(xvalues[i]); for (int i = 0; i < n; i++) writeWord(yvalues[i]); writeWord(color); getACK(); }
void BitmapWriter::writeInfoHeader(struct infoheader & infoheader, FILE * file) { writeDWord(infoheader.size, file); writeDWord(infoheader.width, file); writeDWord(infoheader.height, file); writeWord(infoheader.planes, file); writeWord(infoheader.bitCount, file); writeDWord(infoheader.compression, file); writeDWord(infoheader.imageSize, file); writeDWord(infoheader.xPixelsPerMeter, file); writeDWord(infoheader.yPixelsPerMeter, file); writeDWord(infoheader.colorUsed, file); writeDWord(infoheader.colorImportant, file); }
void picaso4d::gfx_Slider(uint16_t mode, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color, uint16_t scale, uint16_t value) { writeWord(0xFFAE); writeWord(mode); writeWord(x1); writeWord(y1); writeWord(x2); writeWord(y2); writeWord(color); writeWord(scale); writeWord(value); getACK(); }
void SX1509::pinDir(byte pin, byte inOut) { // The SX1509 RegDir registers: REG_DIR_B, REG_DIR_A // 0: IO is configured as an output // 1: IO is configured as an input byte modeBit; if ((inOut == OUTPUT) || (inOut == ANALOG_OUTPUT)) modeBit = 0; else modeBit = 1; unsigned int tempRegDir = readWord(REG_DIR_B); if (modeBit) tempRegDir |= (1<<pin); else tempRegDir &= ~(1<<pin); writeWord(REG_DIR_B, tempRegDir); // If INPUT_PULLUP was called, set up the pullup too: if (inOut == INPUT_PULLUP) writePin(pin, HIGH); if (inOut == ANALOG_OUTPUT) { ledDriverInit(pin); } }
void push(Word value) { setSP(sp() - 2); if (sp() == length + 0x100) runtimeError("Stack overflow"); writeWord(value, sp(), 2); }
void write(Word value, Word offset, int seg = -1) { if (wordSize) writeWord(value, offset, seg); else writeByte(value, offset, seg); }
/******************************************************************** * Write a sentence (multiple words) to the socket ********************************************************************/ void writeSentence(int fdSock, struct Sentence *stWriteSentence) { int iIndex; if (stWriteSentence->iLength == 0) { return; } DEBUG ? printf("Writing sentence\n") : 0; DEBUG ? printSentence(stWriteSentence) : 0; for (iIndex = 0; iIndex < stWriteSentence->iLength; iIndex++) { writeWord(fdSock, stWriteSentence->szSentence[iIndex]); } writeWord(fdSock, ""); }
void picaso4d::gfx_Orbit(uint16_t angle, uint16_t distance, uint16_t * xdest, uint16_t * ydest) { writeWord(0x0012); writeWord(angle); writeWord(distance); getACK(); timeout = 0; while ( timeout < 1000 ) { if (DISPLAY_SERIAL.available() > 3) { *xdest = DISPLAY_SERIAL.read() << 8; *xdest |= DISPLAY_SERIAL.read(); *ydest = DISPLAY_SERIAL.read() << 8; *ydest |= DISPLAY_SERIAL.read(); return; } } }
void picaso4d::gfx_Button(uint16_t state, uint16_t x, uint16_t y, uint16_t buttonColour, uint16_t txtColour, uint16_t font, uint16_t txtWidth, uint16_t txtHeight, char * text) { writeWord(0x0011); writeWord(state); writeWord(x); writeWord(y); writeWord(buttonColour); writeWord(txtColour); writeWord(font); writeWord(txtWidth); writeWord(txtHeight); DISPLAY_SERIAL.print(text); getACK(); }
/********************************************************************* * @fn xferBuf * * @brief Xfers an NV buffer from one location to another, enforcing OSAL_NV_WORD_SIZE writes. * * @return none */ static void xferBuf( uint8 srcPg, uint16 srcOff, uint8 dstPg, uint16 dstOff, uint16 len ) { uint8 rem = dstOff % OSAL_NV_WORD_SIZE; uint8 tmp[OSAL_NV_WORD_SIZE]; if ( rem ) { dstOff -= rem; HalFlashRead(dstPg, dstOff, tmp, OSAL_NV_WORD_SIZE); while ( (rem < OSAL_NV_WORD_SIZE) && len ) { HalFlashRead(srcPg, srcOff, tmp+rem, 1); srcOff++; rem++; len--; } writeWord( dstPg, dstOff, tmp ); dstOff += OSAL_NV_WORD_SIZE; } rem = len % OSAL_NV_WORD_SIZE; len /= OSAL_NV_WORD_SIZE; while ( len-- ) { HalFlashRead(srcPg, srcOff, tmp, OSAL_NV_WORD_SIZE); srcOff += OSAL_NV_WORD_SIZE; writeWord( dstPg, dstOff, tmp ); dstOff += OSAL_NV_WORD_SIZE; } if ( rem ) { uint8 idx = 0; HalFlashRead(dstPg, dstOff, tmp, OSAL_NV_WORD_SIZE); while ( rem-- ) { HalFlashRead(srcPg, srcOff, tmp+idx, 1); srcOff++; idx++; } writeWord( dstPg, dstOff, tmp ); } }
void XMFileBase::writeWords(const mp_uword* buffer,mp_sint32 count) { for (mp_sint32 i = 0; i < count; i++) { writeWord(*buffer); buffer++; } }
void writeGlobalSettings() { eepromSetValid(); cli(); writeByte(2, mode); writeWord(3, tuningSetting); sei(); }
/********************************************************************* * @fn setXferPage * * @brief Set active page header state to be transfer state. * * @param none * * @return none */ static void setXferPage(void) { uint32 pgHdr; // erase difference bit between active state and xfer state pgHdr = OSAL_NV_XFER_PAGE_STATE; writeWord( activePg, OSAL_NV_PAGE_HDR_OFFSET, (uint8*)&pgHdr ); }
void picaso4d::gfx_TriangleFilled(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, uint16_t color) { writeWord(0xFFA9); writeWord(x1); writeWord(y1); writeWord(x2); writeWord(y2); writeWord(x3); writeWord(y3); writeWord(color); getACK(); }
/** write a single bit in a 16-bit device register. * @param devAddr I2C slave device address or Slave Select pin if SPI * @param regAddr Register regAddr to write to * @param bitNum Bit position to write (0-15) * @param value New bit value to write * @return Status of operation (true = success) */ mraa_result_t I2Cdev::writeBitW (uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data) { uint16_t w; mraa_result_t result; if ((result = readWord (devAddr, regAddr, &w)) == MRAA_SUCCESS) { w = (data != 0) ? (w | (1 << bitNum)) : (w & ~(1 << bitNum)); return writeWord (devAddr, regAddr, w); } else return result; }
void max7301::portPullup(uint16_t data) { if (data == HIGH){ _gpioState = 0xFFFF; } else if (data == LOW){ _gpioState = 0x0000; } else { _gpioState = data; } writeWord(GPPU, _gpioState); }
void max7301::gpioPort(uint16_t value){ if (value == HIGH){ _gpioState = 0xFFFF; } else if (value == LOW){ _gpioState = 0x0000; } else { _gpioState = value; } writeWord(GPIO,_gpioState); }
/********************************************************************* * @fn writeItem * * @brief Writes an item header/data combo to the specified NV page. * * @param pg - Valid NV Flash page. * @param id - Valid NV item Id. * @param len - Byte count of the data to write. * @param buf - The data to write. If NULL, no data/checksum write. * @param flag - TRUE if the checksum should be written, FALSE otherwise. * * @return TRUE if header/data to write matches header/data read back, else FALSE. */ static uint8 writeItem( uint8 pg, uint16 id, uint16 len, void *buf, uint8 flag ) { uint16 offset = pgOff[pg-OSAL_NV_PAGE_BEG]; uint8 rtrn = FALSE; osalNvHdr_t hdr; hdr.id = id; hdr.len = len; writeWord( pg, offset, (uint8 *)&hdr ); HalFlashRead(pg, offset, (uint8 *)(&hdr), OSAL_NV_HDR_SIZE); if ( (hdr.id == id) && (hdr.len == len) ) { if ( flag ) { hdr.chk = calcChkB( len, buf ); offset += OSAL_NV_HDR_SIZE; if ( buf != NULL ) { writeBuf( pg, offset, len, buf ); } if ( hdr.chk == calcChkF( pg, offset, len ) ) { if ( hdr.chk == setChk( pg, offset, hdr.chk ) ) { hotItemUpdate(pg, offset, hdr.id); rtrn = TRUE; } } } else { rtrn = TRUE; } len = OSAL_NV_ITEM_SIZE( hdr.len ); } else { len = OSAL_NV_ITEM_SIZE( hdr.len ); if (len > (OSAL_NV_PAGE_SIZE - pgOff[pg - OSAL_NV_PAGE_BEG])) { len = (OSAL_NV_PAGE_SIZE - pgOff[pg - OSAL_NV_PAGE_BEG]); } pgLost[pg - OSAL_NV_PAGE_BEG] += len; } pgOff[pg - OSAL_NV_PAGE_BEG] += len; return rtrn; }