Converting from AVR-GCC to Arduino

First, my conversations can cause errors because I do not speak English, I use Google Translator.
The subject is this: I have a code made for LED Matrix HUB08 Protocol (HUB08 - Тест матрицы с HUB08 протоколом: прокрутка текста - YouTube) but, it is for AVR-GCC and I would like to use this code in Arduino. I believe that for those who understand the subject, be easy; could anyone, by great kindness, help me and convert (if that word) this code to use in Arduino?
The code "main.c" is in the link (youtube above) but I leave here:

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <util/delay.h>

#include "pins.h"
#include "matrix.h"
#include "rtc.h"
#include "fonts.h"

static char *mkNumberString(int16_t value, uint8_t width, uint8_t prec, uint8_t lead)
{
 static char strbuf[8];

 uint8_t sign = lead;
 int8_t pos;

 if (value < 0) {
   sign = '-';
   value = -value;
 }

 // Clear buffer and go to it's tail
 for (pos = 0; pos < width + prec; pos++)
   strbuf[pos] = lead;
 strbuf[pos--] = '\0';

 // Fill buffer from right to left
 while (value > 0 || pos > width - 2) {
   if (prec && (width - pos - 1 == 0))
     strbuf[pos--] = '.';
   strbuf[pos] = value % 10 + 0x30;
   pos--;
   value /= 10;
 }

 if (pos >= 0)
   strbuf[pos] = sign;

 return strbuf;
}

int main(void)
{
 matrixInit();
 sei();

 matrixSetBr(4);

 matrixSetFont(font_matrix_16, 1);
 matrixLoadOutString("Large  ");
 matrixShow(ROW_BOTH, EFFECT_SCROLL_UP);

 DDR(BUZZER) |= BUZZER_LINE;
 PORT(BUZZER) &= ~BUZZER_LINE;
 _delay_ms(50);
 PORT(BUZZER) |= BUZZER_LINE;

 matrixClear(ROW_BOTH, EFFECT_NONE);

 while (1) {
   rtcReadTime();
   matrixSetCol(0, ROW_BOTH);
   matrixSetFont(font_matrix_16, 1);
   matrixLoadOutString(mkNumberString(rtc.hour, 2, 0, '0'));
   matrixLoadOutString(":");
   matrixLoadOutString(mkNumberString(rtc.min, 2, 0, '0'));
   matrixSetFont(font_matrix_08, 1);
   matrixSetCol(55, ROW_TOP);
   matrixLoadOutString(mkNumberString(rtc.sec, 2, 0, '0'));
   matrixSetCol(55, ROW_BOTTOM);
   matrixLoadOutString(mkNumberString(rtc.date, 2, 0, '0'));
   matrixShow(ROW_BOTH, EFFECT_NONE);
 }

 while (1) {
   matrixSetFont(font_matrix_08, 1);
   matrixClear(ROW_BOTH, EFFECT_SCROLL_DOWN);
   matrixSetCol(0, ROW_TOP);
   matrixLoadOutString("Top");
   matrixSetCol(9, ROW_BOTTOM);
   matrixLoadOutString("Low");
   matrixSetFont(font_matrix_16, 1);
   matrixSetCol(30, ROW_BOTH);
   matrixLoadOutString("Big");
   matrixShow(ROW_BOTH, EFFECT_SCROLL_UP);
   _delay_ms(1000);

   matrixSetFont(font_matrix_16, 1);
   matrixLoadScrollString(" Scroll");
   matrixLoadScrollString(" large font");
   matrixScroll(SCROLL_START, ROW_BOTH);
   matrixSetCol(0, ROW_TOP);
   matrixLoadOutString("Large  ");
   _delay_ms(3000);
   matrixShow(ROW_BOTH, EFFECT_SCROLL_UP);
   _delay_ms(1000);

   matrixClear(ROW_BOTH, EFFECT_SCROLL_DOWN);
   matrixSetFont(font_matrix_08, 1);
   matrixLoadScrollString("Scroll");
   matrixLoadScrollString(" top line");
   matrixScroll(SCROLL_START, ROW_TOP);
   matrixSetCol(0, ROW_BOTTOM);
   matrixLoadOutString("Small");
   matrixLoadOutString(" font");
   _delay_ms(1000);
   matrixShow(ROW_BOTTOM, EFFECT_SCROLL_UP);
   _delay_ms(1000);

   matrixSetFont(font_matrix_08, 1);
   matrixLoadScrollString("Scroll");
   matrixLoadScrollString(" bottom line");
   matrixScroll(SCROLL_START, ROW_BOTTOM);
   matrixSetCol(0, ROW_TOP);
   matrixLoadOutString("Small");
   matrixLoadOutString(" font");
   _delay_ms(1000);
   matrixShow(ROW_TOP, EFFECT_SCROLL_DOWN);
   _delay_ms(1000);
 }

 return 0;
}

My thanks to everyone

Que lingua falas??

Este pedaço de código:

  while (1) {
    matrixSetFont(font_matrix_08, 1);
    matrixClear(ROW_BOTH, EFFECT_SCROLL_DOWN);
    matrixSetCol(0, ROW_TOP);
    matrixLoadOutString("Top");
    matrixSetCol(9, ROW_BOTTOM);
    matrixLoadOutString("Low");
    matrixSetFont(font_matrix_16, 1);
    matrixSetCol(30, ROW_BOTH);
    matrixLoadOutString("Big");
    matrixShow(ROW_BOTH, EFFECT_SCROLL_UP);
    _delay_ms(1000);

    matrixSetFont(font_matrix_16, 1);
    matrixLoadScrollString(" Scroll");
    matrixLoadScrollString(" large font");
    matrixScroll(SCROLL_START, ROW_BOTH);
    matrixSetCol(0, ROW_TOP);
    matrixLoadOutString("Large  ");
    _delay_ms(3000);
    matrixShow(ROW_BOTH, EFFECT_SCROLL_UP);
    _delay_ms(1000);

    matrixClear(ROW_BOTH, EFFECT_SCROLL_DOWN);
    matrixSetFont(font_matrix_08, 1);
    matrixLoadScrollString("Scroll");
    matrixLoadScrollString(" top line");
    matrixScroll(SCROLL_START, ROW_TOP);
    matrixSetCol(0, ROW_BOTTOM);
    matrixLoadOutString("Small");
    matrixLoadOutString(" font");
    _delay_ms(1000);
    matrixShow(ROW_BOTTOM, EFFECT_SCROLL_UP);
    _delay_ms(1000);

    matrixSetFont(font_matrix_08, 1);
    matrixLoadScrollString("Scroll");
    matrixLoadScrollString(" bottom line");
    matrixScroll(SCROLL_START, ROW_BOTTOM);
    matrixSetCol(0, ROW_TOP);
    matrixLoadOutString("Small");
    matrixLoadOutString(" font");
    _delay_ms(1000);
    matrixShow(ROW_TOP, EFFECT_SCROLL_DOWN);
    _delay_ms(1000);
  }

nunca corre...

Oi bubulindo! Falo o Português Brasil! certamente, como vc!! rsrsrs... Achei q este fórum fosse somente Inglês!
Aliás, não tinha percebido em cima, no cabeçalho: Arduino Forum > International > Portugues
Então, o que vc me diz deste código? Quem sabe te interessa tb?
Até mesmo, baixei o Atmel Studio 7.0 e tentei carregar este código no mesmo mas, não soube fazer direito; quase deu certo mas, acho q faltou o quase!!
Li em vários lugares/sites sobre como abrir e/ou converter esse tipo de arquivo e alguns citam o Atmel Studio como aqui: Programar Arduino Uno en C con Atmel Studio – MaGno e aqui: Primeiros passos com Atmel Studio - Embarcados
O que eu quero é fazer do jeito mais fácil: abrir e gravar o código com o Atmel Studio ou adaptar o código no Arduino. Aprecio sua ajuda,

De onde vc é?

Abçs

Daniel

Eu falo Português... de Portugal.

De onde tiraste esse código? Foste tu que o escreveste?

Porque queres converter para o Arduino, se o código funciona, certamente que pode ser carregado para um Arduino sem passar pela IDE e linguagem do Arduino.

Mas adiante... depois de copiares as bibliotecas usadas nesse código para o Arduino (podes procurar isso online), só tens de copiar isso para um sketch do Arduino.

A função main() é dividida em duas partes. O código antes do while(1), metes na função setup() e o que estiver dentro do while(1) vai para dentro da função loop().

Oi bubulindo! Primeiramente, obrigado por me responder.

Ñ fui eu que escrevi o código, o mesmo tirei daqui: https://www.youtube.com/watch?v=-XuD8ideQZo

Sim, certamente funciona mas, quero converter para o Arduino porque, segundo o autor, foi feito para AVR-GCC e eu não sei como abrir e gravar no Arduino ou no ATmega328P. Já tentei abrir com o Atmel Studio 7.0 mas não consegui os passos corretos; não sei se realmente pode ser aberto nesse programa.

Tentarei fazer como você falou mas, não sei se irei conseguir... depois lhe deixo saber;

Todas essas bibliotecas, coloco em pastas separadas, dentro da pasta libraries do Arduino?

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <util/delay.h>

#include "pins.h"
#include "matrix.h"
#include "rtc.h"
#include "fonts.h"

E os textos após as bibliotecas, antes de void setup() deixo como está?

static char ...
...
...

return strbuf;
}

Se você quiser, dê uma olhada aqui para ver os arquivos: GitHub - WiseLord/hub08lib

Obrigado++

Esses arquivos são de quê? Das bibliotecas? De onde copiaste o código?

Estas:

#include "pins.h"
#include "matrix.h"
#include "rtc.h"
#include "fonts.h"

são as bibliotecas que tens de copiar.

Sim, o código fora da função main() tem de ser passado para o arduino também.

Oi bubulindo, o código tirei daqui: GitHub - WiseLord/hub08lib

Se você se interessar em adaptá-lo ao Arduino, por favor, me envie! Obrigado