static int writeCells (BrailleDisplay *brl) { static const unsigned char beginSequence[] = {ESC, 'Z', '1'}; static const unsigned char endSequence[] = {CR}; unsigned char buffer[sizeof(beginSequence) + sizeof(statusCells) + sizeof(textCells) + sizeof(endSequence)]; unsigned char *byte = buffer; byte = mempcpy(byte, beginSequence, sizeof(beginSequence)); byte = translateOutputCells(byte, statusCells, sizeof(statusCells)); byte = translateOutputCells(byte, textCells, sizeof(textCells)); byte = mempcpy(byte, endSequence, sizeof(endSequence)); return writeData(brl, buffer, byte-buffer); }
static int writeCells (BrailleDisplay *brl) { const size_t count = MIN(brl->textColumns*brl->textRows, MAXIMUM_CELL_COUNT); unsigned char cells[count]; translateOutputCells(cells, brl->data->previousCells, count); return writePacket(brl, 0XFC, 0X01, cells, count, NULL, 0); }
static int writeBrailleCells (BrailleDisplay *brl) { size_t count = brl->textColumns; unsigned char cells[count]; translateOutputCells(cells, brailleCells, count); return writePacket(brl, 1, cells, count); }
static int brl_writeWindow(BrailleDisplay *brl, const wchar_t *text) { unsigned char *byte = rawdata; /* This Braille Line need to display all information, include status */ /* Make status info to rawdata */ byte = translateOutputCells(byte, Status, model->NbStCells); /* step a physical space with main cells */ *byte++ = 0; /* Make main info to rawdata */ byte = translateOutputCells(byte, brl->buffer, brl->textColumns); /* Write to Braille Display */ WriteToBrlDisplay(rawdata); return 1; }
static int refreshCells (BrailleDisplay *brl) { unsigned char buffer[1 + cellCount]; unsigned char *byte = buffer; *byte++ = BN_REQ_WRITE; byte = translateOutputCells(byte, cellBuffer, cellCount); return writePacket(brl, buffer, byte-buffer); }
static int brl_writeWindow (BrailleDisplay *brl, const wchar_t *text) { if (cellsHaveChanged(brl->data->textCells, brl->buffer, brl->textColumns, NULL, NULL, &brl->data->forceRewrite)) { unsigned char cells[brl->textColumns]; translateOutputCells(cells, brl->data->textCells, brl->textColumns); if (!writeBrailleCells(brl, cells, brl->textColumns)) return 0; } return 1; }
/* the one alreadz displayed */ static int brl_writeWindow(BrailleDisplay *brl, const wchar_t *text) { static unsigned char brailleDisplay[81]= { 0x3e }; /* should be large enough for everyone */ static unsigned char prevData[80]; if (cellsHaveChanged(prevData, brl->buffer, brl->textColumns, NULL, NULL, NULL)) { translateOutputCells(brailleDisplay+1, brl->buffer, brl->textColumns); if (brl_writePacket(brl, (unsigned char *)&brailleDisplay, brl->textColumns+1) == -1) return 0; } return 1; }
static int writeCells (BrailleDisplay *brl) { static const unsigned char header[] = {'D'}; static const unsigned char trailer[] = {CR}; unsigned char buffer[sizeof(header) + brl->textColumns + sizeof(trailer)]; unsigned char *byte = buffer; byte = mempcpy(byte, header, sizeof(header)); byte = translateOutputCells(byte, outputBuffer, brl->textColumns); byte = mempcpy(byte, trailer, sizeof(trailer)); return writeBytes(brl, buffer, byte-buffer); }
static int writeRequest (BrailleDisplay *brl) { if (brl->data->acknowledgementHandler) return 1; if (brl->data->configFlags) { if (!writePacket(brl, FS_PKT_CONFIG, brl->data->configFlags, 0, 0, NULL)) { return 0; } setAcknowledgementHandler(brl, handleConfigAcknowledgement); return 1; } if (brl->data->firmnessSetting >= 0) { if (!writePacket(brl, FS_PKT_HVADJ, brl->data->firmnessSetting, 0, 0, NULL)) { return 0; } setAcknowledgementHandler(brl, handleFirmnessAcknowledgement); return 1; } if (brl->data->writeLast != -1) { unsigned int count = brl->data->writeLast + 1 - brl->data->writeFirst; unsigned char buffer[count]; int truncate = count > brl->data->outputPayloadLimit; if (truncate) count = brl->data->outputPayloadLimit; translateOutputCells(buffer, &brl->data->outputBuffer[brl->data->writeFirst], count); if (!writePacket(brl, FS_PKT_WRITE, count, brl->data->writeFirst, 0, buffer)) { return 0; } setAcknowledgementHandler(brl, handleWriteAcknowledgement); brl->data->writingFirst = brl->data->writeFirst; if (truncate) { brl->data->writingLast = (brl->data->writeFirst += count) - 1; } else { brl->data->writingLast = brl->data->writeLast; brl->data->writeFirst = -1; brl->data->writeLast = -1; } return 1; } return 1; }
static int brl_writeWindow(BrailleDisplay *brl, const wchar_t *text) { const size_t cells = 40; unsigned char outbuff[cells]; /* Only display something if the data actually differs, this * could most likely cause some problems in redraw situations etc * but since the darn thing wants to redraw quite frequently otherwise * this still makes a better lookin result */ if (cellsHaveChanged(lastbuff, brl->buffer, cells, NULL, NULL, NULL)) { translateOutputCells(outbuff, brl->buffer, cells); vbdisplay(outbuff); vbdisplay(outbuff); brl->writeDelay += VBREFRESHDELAY; } return 1; }
static int brl_writeWindow (BrailleDisplay *brl, const wchar_t *text) { int textChanged = cellsHaveChanged(prevdata, brl->buffer, brl->textColumns*brl->textRows, NULL, NULL, NULL); int statusChanged = cellsHaveChanged(oldstatus, status, 5, NULL, NULL, NULL); short i; /* loop counter */ unsigned char *pre_data = (unsigned char *)"\002\033Z"; /* bytewise accessible copies */ unsigned char *post_data = (unsigned char *)"\001\015"; /* Only refresh display if the data has changed: */ if (textChanged || statusChanged) { /* Dot mapping from standard to MultiBraille: */ translateOutputCells(brl->buffer, brl->buffer, brl->textColumns*brl->textRows); rawlen = 0; if (pre_data[0]) { memcpy (rawdata + rawlen, pre_data + 1, pre_data[0]); rawlen += pre_data[0]; } /* HACK - ALERT ;-) * 6th module is a dummy-modul and not wired! * but I need to but a dummy char at the beginning, else the stati are shifted ... */ rawdata[rawlen++] = 0; /* write stati */ for (i = 0; i < 5; i++) { rawdata[rawlen++] = status[i]; } /* write braille message itself */ for (i = 0; i < brl->textColumns * brl->textRows; i++) { rawdata[rawlen++] = brl->buffer[i]; } if (post_data[0]) { memcpy (rawdata + rawlen, post_data + 1, post_data[0]); rawlen += post_data[0]; } serialWriteData (MB_serialDevice, rawdata, rawlen); } return 1; }
static int sendData (unsigned char line, unsigned char column, unsigned char count) { unsigned char data[5 + count]; unsigned char *target = data; unsigned char *source = &targetImage[line][column]; *target++ = 0XFF; *target++ = line + 1; *target++ = (line == cursorRow)? cursorColumn+1: 0; *target++ = column + 1; *target++ = count; logBytes(LOG_DEBUG, "Output dots", source, count); target = translateOutputCells(target, source, count); count = target - data; logBytes(LOG_DEBUG, "LogText write", data, count); if (checkData(data, count)) { if (sendBytes(data, count)) { return 1; } } return 0; }
static int brl_writeStatus (BrailleDisplay *brl, const unsigned char *s) { /* Dot mapping: */ translateOutputCells(status, s, 5); return 1; }