void Lcd_t::PrintfFont(const uint8_t *PFont, uint8_t x, uint8_t y, const char *S, ...) { // Print to buf FntBuf.Cnt = 0; va_list args; va_start(args, S); kl_vsprintf(FLcdPutFontChar, FNT_CHAR_BUF_SZ, S, args); va_end(args); // Display what printed uint32_t height = PFont[2], MaxWidth = PFont[1]; uint8_t FirstSymbolCode = PFont[0]; for(uint32_t i=0; i<FntBuf.Cnt; i++) { char c = FntBuf.Buf[i]; // ==== Draw char ==== uint8_t *P = (uint8_t*)PFont + 3 + (c - FirstSymbolCode) * (MaxWidth*height + 1); // Pointer to char uint32_t width = 1 + *P++; for(uint8_t i=0; i<width; i++) { for(uint8_t h=0; h<height; h++) { uint32_t Indx = x + i + (y + h) * 96; uint32_t dw = *P++; dw = __RBIT(dw); dw >>= 23; uint16_t w = dw | 0x0001; IBuf[Indx] = w; } } S++; x += width; } }
void Lcd_t::Printf(const uint8_t x, const uint8_t y, const char *S, ...) { GotoCharXY(x, y); va_list args; va_start(args, S); kl_vsprintf(FLcdPutChar, 16, S, args); va_end(args); }
void Lcd_t::PrintfInverted(const uint8_t x, const uint8_t y, const char *S, ...) { msg_t msg = chSemWait(&semLcd); if(msg == RDY_OK) { GotoCharXY(x, y); va_list args; va_start(args, S); kl_vsprintf(FLcdPutCharInverted, 16, S, args); va_end(args); chSemSignal(&semLcd); } }
void CmdUart_t::Printf(const char *format, ...) { uint32_t MaxLength = (PWrite < PRead)? (PRead - PWrite) : ((UART_TXBUF_SIZE + PRead) - PWrite); va_list args; va_start(args, format); IFullSlotsCount += kl_vsprintf(FPutChar, MaxLength, format, args); va_end(args); // Start transmission if Idle if(IDmaIsIdle) { IDmaIsIdle = false; dmaStreamSetMemory0(UART_DMA_TX, PRead); uint32_t PartSz = (TXBuf + UART_TXBUF_SIZE) - PRead; // Char count from PRead to buffer end ITransSize = (IFullSlotsCount > PartSz)? PartSz : IFullSlotsCount; // How many to transmit now dmaStreamSetTransactionSize(UART_DMA_TX, ITransSize); dmaStreamSetMode(UART_DMA_TX, UART_DMA_TX_MODE); dmaStreamEnable(UART_DMA_TX); } }
void Uart_t::PrintfNow(const char *S, ...) { va_list args; va_start(args, S); kl_vsprintf(FPutCharNow, 99999, S, args); va_end(args); }
void Uart_t::IPrintf(const char *format, va_list args) { int32_t MaxLength = UART_TXBUF_SZ - IFullSlotsCount; IFullSlotsCount += kl_vsprintf(FPutChar, MaxLength, format, args); // Start transmission if Idle if(IDmaIsIdle) ISendViaDMA(); }
void PrintfCNow(const char *format, ...) { va_list args; va_start(args, format); kl_vsprintf(FPutCharNow, 99999, format, args); va_end(args); }
void UsbCDC_t::Printf(const char *format, ...) { va_list args; va_start(args, format); kl_vsprintf(uFPutChar, 0xFFFF, format, args); va_end(args); }