Coder Social home page Coder Social logo

rocorbera / bluevga Goto Github PK

View Code? Open in Web Editor NEW
60.0 60.0 11.0 4.33 MB

VGA library for STM32F103C (BluePill) that can manipulate a screen with 28x30 tiles with 8x8 pixels each, in a total resolution of 224x240 pixels with 8 colors using a very low footprint

License: Other

C++ 75.05% C 24.95%
arduino arduino-ide bare-metal bitmap bluepill display games graphics stm32 stm32f103 stm32f103c8 tile vga vga-library vga-monitor

bluevga's People

Contributors

rocorbera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bluevga's Issues

show picture

Hi,
how can i show 64*44 image in red color and show text behind it in green color?
do you have any sample?
Regards.

Stm32H7 port?

Hello again, how do you think of STM32H7 with 1024kb mem and 480mhz / 550mhz clock? Then vga 640x480 @ 60 hz is achievable?

Question about tile size customization

Hello @RoCorbera ... Nice library...

But how it can be customized,

I need 24x14 grid for 28x34 px tile size.

To display in 640x480 resolution.

I know that I need black padding 4px Horisontaly [top,bottom]and 2px vertically[left,right]... But do you think stm32 is powefrull enough to drive full 640x480 resolution with around 90 custom maped characters at this size of tile

?

I2C disabled when rendering image on the screen

Like the project. I am trying to use my stm32 as display renderer, so I needed to make it as i2c slave and set the Wire pins to I2C2. Arduino nano is sending over i2c letters to put on the display. It doesn't work while it is displaying, only before displaying image. I know that the code relies on hardware timer, so delay, pwm etc doesn't work, but does it also disable i2c and spi interfaces?

STM32 code:

#include <Wire.h>
#include "bluevga.h"
#include "font.h"            // imports a ASCII Flash font bitmap
#include "bluebitmap.h"      // functions for drawing pixels in the screen

#define LED_PIN PB12

BlueVGA vga(ASCII_FONT);
//BlueVGA vga(USE_RAM);

uint8_t color_code = vga.getColorCode(RGB_WHITE, RGB_BLACK);
BlueBitmap fontBitmap(8, 8, (uint8_t *)ASCII_FONT);

volatile char text_buffer[VRAM_HEIGHT][VRAM_WIDTH] = {0};

volatile bool blink_led = true;

static void twi_receive(int bytes);
static void twi_request(void);

void setup() {
    Wire.setSCL(PB10);
    Wire.setSDA(PB11);
    Wire.begin(4);
    Wire.onReceive(twi_receive);
    Wire.onRequest(twi_request);

    pinMode(LED_PIN, OUTPUT);
    digitalWrite(LED_PIN, LOW);

    {
        uint8_t tx = 0;
        uint8_t ty = 0;
        for (char letter = 32; letter < 127; letter++)
        {
            text_buffer[ty][tx++] = letter;
            if (tx >= 28)
            {
                tx = 0;
                ty++;
            }
        }
    }

    vga.clearScreen(color_code);
}

void loop() 
{
    BlueBitmap::eraseRamTiles();
    for(uint8_t y = 0; y < VRAM_HEIGHT; y++)
    {
        char* line = (char*)text_buffer[y];
        vga.printStr(0, y, color_code, line);
    }

    if (blink_led)
    {
        digitalWrite(LED_PIN, HIGH);
        vga.waitVSync(60);
        digitalWrite(LED_PIN, LOW);
        vga.waitVSync(60);
        blink_led = false;
    }
}

// Write from Master, Read from Slave
static void twi_receive(int bytes)
{
    if (bytes != 3)
        return;

    uint8_t buffer[3];
    Wire.readBytes(buffer, 3);
    uint8_t x = buffer[0];
    uint8_t y = buffer[1];
    uint8_t c = buffer[2];
    text_buffer[y][x] = c;
    blink_led = true;
}

// Read from Master, Write from Slave
static void twi_request(void)
{
    
}

Arduino Nano code:

#include <Arduino.h>
#include <Wire.h>

static void write_vga(uint8_t x, uint8_t y, uint8_t c);

void setup() 
{
    Wire.begin();
}

void loop() 
{
    write_vga(0, 0, 'A');
    write_vga(1, 0, 'B');
    write_vga(2, 0, 'C');
}

static void write_vga(uint8_t x, uint8_t y, uint8_t c)
{
    Wire.beginTransmission(4);
    Wire.write(x);
    Wire.write(y);
    Wire.write(c);
    Wire.endTransmission();
}

CRT VGA Monitor Image Problem & Fake Bluepill Issues

Hello, I have a problem with the signals. The image is distorted in some horizontal lines.

20201122_164817

I confirm that the problem is in the Sync signals, because shorting any color signal with the horizontal Sync signal, the image is also distorted.

20201122_170337

I tried other sketches and libraries, and they worked correctly, I tried to program the microcontroller with both cores, changing the bootloaders, trying another Blue Pill, but I couldn't get it to work.

For some reason, the problem is slightly greater when there are more colors displayed on the screen.

Any help is appreciated.

Display the temperature of DHT11 sensor on VGA

Hello, I am trying to use DHT11 to match your cool library to complete the temperature display. I found that the official DHT11 library cannot be used. I try to use the capture mode of the hardware timer to complete the driver. It works successfully, but it needs to pull it down for 18ms in the initial stage, I can't use vga.waitVSync(2) to complete the delay, I can only modify the source file to unlock the systick and use delay(18) to complete the pull down, But this seems to cause the screen to flicker. How should I solve this delay problem?

Below is my arduino code.

void Request()      /* Microcontroller send request */
{
  pinMode(DHT11, OUTPUT);
  digitalWrite(DHT11,LOW);    /* set to low pin */
  delay(18); /* wait for 18ms */
//vga.waitVSync(2); /* it not work */
  digitalWrite(DHT11,HIGH);    /* set to high pin */
}

void Response()
{
    pinMode(DHT11, INPUT_PULLUP);
    Timer2.attachCompare1Interrupt(handler_channel_1);
    TIMER2_BASE->CR1 = TIMER_CR1_CEN;
    TIMER2_BASE->CR2 = 0;
    TIMER2_BASE->SMCR = 0;
    TIMER2_BASE->DIER = TIMER_DIER_CC1IE;
    TIMER2_BASE->EGR = 0;
    TIMER2_BASE->CCMR1 = TIMER_CCMR1_CC1S_INPUT_TI1;
    TIMER2_BASE->CCMR2 = 0;
    TIMER2_BASE->CCER = TIMER_CCER_CC1E;
    TIMER2_BASE->PSC = 71;
    TIMER2_BASE->ARR = 0xFFFF;
    TIMER2_BASE->DCR = 0;
}

void handler_channel_1(void) {                           //This function is called when channel 1 is captured.
    if (0b1 & GPIOA_BASE->IDR  >> 0) {                     //If the receiver channel 1 input pulse on A0 is high.
      channel_1_start = TIMER2_BASE->CCR1;                 //Record the start time of the pulse.
      TIMER2_BASE->CCER |= TIMER_CCER_CC1P;                //Change the input capture mode to the falling edge of the pulse.
    }
    else {                                                 //If the receiver channel 1 input pulse on A0 is low.
      channel_1 = TIMER2_BASE->CCR1 - channel_1_start;     //Calculate the total pulse time.
      if (channel_1 < 0)channel_1 += 0xFFFF;               //If the timer has rolled over a correction is needed.
      TIMER2_BASE->CCER &= ~TIMER_CCER_CC1P;               //Change the input capture mode to the rising edge of the pulse.
      a[index1++]=channel_1;
    }
}

multiple definition of `TIM1_CC_IRQHandler';

hi, i would like to use your pretty cool library in order to make a monitor of my car parking sensors but i've got some issues.
first, i installed the library from the new arduino ide 2.0.2 library manager and when i tryed to compile the ''hello world'' sketch i got an issue with ''bluebitmap.cpp'' it seems to have a issue with this line :
''uint32 color32Bits = color << 24 | color << 16 | color << 8 | color;''

i simply replaced with :
''uint32_t color32Bits = color << 24 | color << 16 | color << 8 | color;''

the second issue is that i have this error while compiling : ''multiple definition of `TIM1_CC_IRQHandler';''

have you an idea of how i can fit it ?

i'm working with STM32F103C8T6 (chinese version) and official STM32 Core v2.3.0 (lastest version). also, i'm using HID 2.0 bootloader (lastest version).

thank you.

Stm32H7? Potr?

Hello again, how do you think of STM32H7 with 1024kb mem and 480mhz / 550mhz clock? Then vga 640x480 @ 60 hz is achievable?

Do I need to use any Resistors for VGA pins?

Hi I was going through your project and in the stm32duino thread, (https://stm32duinoforum.com/forum/viewtopic_f_2_t_3318.html). Amazing work! Just out of curiocity, are any resistors required between R,G,B pins of VGA and STM32 mcu? Other 'works' with VGA have several "potential divider" resistors of 220 Ohm as the pins MAX input voltage is ~1V. I am about to walk on your path, so I thought, its better to ask you before damaging something. ๐Ÿ˜‡

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.