
Originally Posted by
stahta01
Warning: C++ Libraries normally need to be used with the exact C++ compiler that created them!
Tim S.
What you mean exactly ?
What I'm doing wrong ?

Originally Posted by
Zeus_
Just a tip: It's a terrible terrible idea to try and use graphics.h in C::B. Speaking from personal experience. Invest time in learning something like OpenGL or DirectX or Metal, etc as I highly doubt graphics.h being used anywhere in the present except maybe in India for school projects on Turbo C++.
I'm sorry I didn't explain my main goal for going with something that is relatively low level and of course old programming style.
Actually I'm trying to work with pixels because I'm working with embedded systems graphics on LCDs that have simple drivers which work on drawing pixels from bitmaps.
So I'm trying to learn some skills of working with pixels because the whole library is based on learning how a pixel is drawn on the LCD and at which frame buffer pattern.
This is the library I'm working on now. It's for 0.96" LCD for microcontrollers projects.
Code:
#include <avr/pgmspace.h>#include <stdlib.h>
#include <Wire.h>
#include "ssd1306_stm32.h"
#include "ssd1306_stm32_arrays.h"
#ifndef swap
#define swap(a, b) { int16_t t = a; a = b; b = t; }
#endif
// lcd draw functions
/* void ssd1306_(){}
void ssd1306_(){}
void ssd1306_(){}
void ssd1306_(){}
void ssd1306_(){} */
// the most basic function, set a single pixel
void ssd1306_drawPixel(int16_t x, int16_t y, uint16_t color){
if ((x < 0) || (x >= width) || (y < 0) || (y >= height))
return;
// check rotation, move pixel around if necessary
switch (rotation) {
case 1:
swap(x, y);
x = width - x - 1;
break;
case 2:
x = width - x - 1;
y = height - y - 1;
break;
case 3:
swap(x, y);
y = height - y - 1;
break;
}
// x is which column
switch (color)
{
case WHITE: buffer[x+ (y/8)........D1306_WIDTH] |= (1 << (y&7)); break;
case BLACK: buffer[x+ (y/8)........D1306_WIDTH] &= ~(1 << (y&7)); break;
case INVERSE: buffer[x+ (y/8)........D1306_WIDTH] ^= (1 << (y&7)); break;
}
}
void ssd1306_byte_write(uint8_t x, uint8_t y, uint8_t data_byte){
ssd1306_cmd(SSD1306_COLUMNADDR); ssd1306_cmd(x); ssd1306_cmd(x);
ssd1306_cmd(SSD1306_PAGEADDR); ssd1306_cmd(y); ssd1306_cmd(y);
ssd1306_data(data_byte);
}
void ssd1306_spec_bitmap(uint8_t x, uint8_t y, uint8_t w,
uint8_t h, const unsigned char * bitmap){
ssd1306_cmd(SSD1306_COLUMNADDR); ssd1306_cmd(x); ssd1306_cmd(x);
ssd1306_cmd(SSD1306_PAGEADDR); ssd1306_cmd(y); ssd1306_cmd(y);
x = 50;
y = ;
for (uint16_t i=x0; i<x1; i++) {
Wire.beginTransmission(_i2caddr);
WIRE_WRITE(DAT_MSK);
for (uint8_t x=0; x<16; x++) {
WIRE_WRITE(pgm_read_byte_near(&bitmap[i]));
i++;
}
i--;
Wire.endTransmission();
}
}
void ssd1306_drawbitmap(int16_t x, int16_t y,
const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color) {
int16_t byteWidth = (w + 7) / 8; // Bitmap scanline pad = whole byte
uint8_t byte = 0;
Wire.beginTransmission(_i2caddr);
WIRE_WRITE(DAT_MSK);
for(int16_t j=0; j<h; j++, y++) {
for(int16_t i=0; i<w; i++) {
if(i & 7) byte <<= 1;
else byte = pgm_read_byte(&bitmap[j * byteWidth + i / 8]);
if(byte & 0x80) writePixel(x+i, y, color);
}
}
endWrite();
}
I just want to save time in uploading a code to the microcontroller everytime and instead work with a similar simulated code with computer programming with drawing pixels on the screen.