Browse Source

my first commit

feature/2015
Martin Herweg 16 years ago
parent
commit
86d4afe23e
  1. 4
      Makefile
  2. 168
      animations/programm.c
  3. 4
      borg_hw/Makefile
  4. 150
      borg_hw/borg_hw_borg_mh.c
  5. 8
      borg_hw/config.in
  6. 45
      borg_hw/config_borg_mh.in
  7. 26
      display_loop.c
  8. 2
      main.c
  9. 77
      pixel.c
  10. 11
      pixel.h
  11. 4
      scrolltext/config.in
  12. 2
      scrolltext/scrolltext3.c

4
Makefile

@ -165,8 +165,10 @@ sflash: $(TARGET).hex
avrdude -p m32 -b 115200 -u -c avr109 -P $(SERIAL) -U f:w:$< -F avrdude -p m32 -b 115200 -u -c avr109 -P $(SERIAL) -U f:w:$< -F
echo X > $(SERIAL) echo X > $(SERIAL)
uflash: $(TARGET).hex
avrdude -c usbasp -p atmega32 -V -U f:w:$< -F
.PHONY: clean mrproper sflash .PHONY: clean mrproper sflash uflash
############################################################################## ##############################################################################
# configure ethersex # configure ethersex
# #

168
animations/programm.c

@ -9,6 +9,7 @@
#ifdef ANIMATION_TESTS #ifdef ANIMATION_TESTS
void test1(){ void test1(){
unsigned char x,y; unsigned char x,y;
for (y=0;y<NUM_ROWS;y++){ for (y=0;y<NUM_ROWS;y++){
for (x=0;x<NUM_COLS;x++){ for (x=0;x<NUM_COLS;x++){
setpixel((pixel){x,y}, 3); setpixel((pixel){x,y}, 3);
@ -25,7 +26,7 @@ void test_level1(){
wait(5); wait(5);
} }
} }
for(;;) wait(100); wait(2000);
} }
void test_level2(){ void test_level2(){
@ -36,7 +37,7 @@ void test_level2(){
wait(5); wait(5);
} }
} }
for(;;) wait(100); wait(2000);
} }
void test_level3(){ void test_level3(){
@ -47,7 +48,7 @@ void test_level3(){
wait(5); wait(5);
} }
} }
for(;;) wait(100); wait(2000);
} }
void test_levels(){ void test_levels(){
@ -68,11 +69,168 @@ void test_palette(){
b=y%4; b=y%4;
for (x=0;x<NUM_COLS;x++){ for (x=0;x<NUM_COLS;x++){
setpixel((pixel){x,y}, b); setpixel((pixel){x,y}, b);
wait(1); // wait(1);
} }
} }
for(;;) wait(100); wait(2000);
} }
void test_palette2(){
unsigned char x,y,b;
for (x=0;x<NUM_COLS;x++){
b=x%4;
for (y=0;y<NUM_ROWS;y++){
setpixel((pixel){x,y}, b);
// wait(1);
}
}
wait(1000);
for (x=0;x<NUM_COLS;x++){
// shift image right
shift_pixmap_l();
wait(30);
}
}
void test_lines(){
unsigned char n, delay=80;
line((pixel){0,0}, (pixel){7,0} ,3);
wait(delay);
line((pixel){7,0}, (pixel){7,7} ,3);
wait(delay);
line((pixel){7,7}, (pixel){0,7} ,3);
wait(delay);
line((pixel){0,7}, (pixel){0,0} ,3);
wait(delay);
line((pixel){7,7}, (pixel){0,0} ,3);
wait(delay);
line((pixel){0,7}, (pixel){7,0} ,3);
wait(delay);
//sunrays
for (n=0;n<=NUMPLANE;n++){
line((pixel){15,0}, (pixel){63,0} ,n);
wait(delay);
line((pixel){15,0}, (pixel){32,7} ,n);
wait(delay);
line((pixel){15,0}, (pixel){63,7} ,n);
wait(delay);
line((pixel){15,0}, (pixel){15,7} ,n);
wait(delay);
}
for (n=NUMPLANE;n!=255;n--){
line((pixel){15,0}, (pixel){63,0} ,n);
wait(delay);
line((pixel){15,0}, (pixel){32,7} ,n);
wait(delay);
line((pixel){15,0}, (pixel){63,7} ,n);
wait(delay);
line((pixel){15,0}, (pixel){15,7} ,n);
}
wait(500);
}
void movinglines(){
unsigned char x,y;
line((pixel){63,7}, (pixel){63,0} ,3);
// linie wandert nach rechts
for (x=0;x<64;x++){
shift_pixmap_l();
wait(10);
}
// von unten nach oben
for (y=7;y!=255;y--){
line((pixel){0,y}, (pixel){63,y} ,3);
wait(20);
line((pixel){0,y}, (pixel){63,y} ,0);
//wait(10);
}
//eine linie von rechts nach links und
// 8 mal von oben nach unten
// gleichzeitig
for (x=0;x<63;x++){
y=x%8;
line((pixel){0,y}, (pixel){63,y} ,3);
line((pixel){x,0}, (pixel){x,7} ,3);
wait(50);
line((pixel){0,y}, (pixel){63,y} ,0);
line((pixel){x,0}, (pixel){x,7} ,0);
//wait(10);
}
}
void rectangles(){
unsigned char x;
unsigned int delay=500;
clear_screen(0);
filled_rectangle((pixel){1,1},4,2,3);
wait(delay);
filled_rectangle((pixel){10,1},5,5,3);
wait(delay);
filled_rectangle((pixel){30,2},30,5,2);
wait(delay);
filled_rectangle((pixel){40,0},8,8,1);
wait(delay);
filled_rectangle((pixel){1,1},4,2,2);
wait(delay);
filled_rectangle((pixel){10,1},5,5,1);
wait(delay);
filled_rectangle((pixel){30,2},30,5,3);
wait(delay);
filled_rectangle((pixel){40,0},8,8,2);
wait(delay);
for (x=0;x<64;x++){
shift_pixmap_l();
wait(30);
}
filled_rectangle((pixel){30,0},8,8,3);
wait(delay);
filled_rectangle((pixel){31,1},6,6,2);
wait(delay);
filled_rectangle((pixel){32,2},4,4,1);
wait(delay);
filled_rectangle((pixel){33,3},2,2,3);
wait(delay);
wait(delay);
wait(delay);
filled_rectangle((pixel){33,3},2,2,1);
wait(delay);
filled_rectangle((pixel){32,2},4,4,2);
wait(delay);
filled_rectangle((pixel){31,1},6,6,3);
wait(delay);
filled_rectangle((pixel){30,0},8,8,1);
wait(delay);
wait(delay);
wait(delay);
wait(delay);
}
#endif #endif
#ifdef ANIMATION_OFF #ifdef ANIMATION_OFF

4
borg_hw/Makefile

@ -18,8 +18,8 @@ ifeq ($(BORG_HW),HW_BORG_LS)
SRC = borg_hw_borg_ls.c SRC = borg_hw_borg_ls.c
endif endif
ifeq ($(BORG_HW),HW_BORG_LS) ifeq ($(BORG_HW),HW_BORG_MH)
SRC = borg_hw_borg_ls.c SRC = borg_hw_borg_mh.c
endif endif
ifeq ($(BORG_HW),HW_BORG_MINI) ifeq ($(BORG_HW),HW_BORG_MINI)

150
borg_hw/borg_hw_borg_mh.c

@ -0,0 +1,150 @@
#include "../config.h"
#include "../makros.h"
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/wdt.h>
#include "borg_hw.h"
#define ROWPORT PORTC
#define ROWDDR DDRC
#define COLPORT PORTA
#define COLDDR DDRA
#define MYPORT PORTC
#define MYPORT2 PORTA
#define SHOW 0
#define DATA 1
#define PIN_ENABLE 0
#define PIN_DATA 1
unsigned char pixmap[NUMPLANE][NUM_ROWS][LINEBYTES];
inline void rowshow(unsigned char row, unsigned char plane){
unsigned char p, n,m, outb, clkmsk;
clkmsk = 0x80>>row;
// if (row==4)
{
MYPORT &= ~(1 << PIN_ENABLE) ;
//MYPORT |= (1 << PIN_ENABLE) ; //hide
// MYPORT |= (1 << PIN_ENABLE) ; //hide
for (n=7;n<8;n--)
{
outb = pixmap[plane][row][n];
p=0x80;
for (m=0;m<8;m++)
{
if (outb & p)
// MYPORT |= (1 << PIN_DATA);
MYPORT &= ~(1 << PIN_DATA) ;
else
// MYPORT &= ~(1 << PIN_DATA) ; //off
MYPORT |= (1 << PIN_DATA);
MYPORT2 &= ~clkmsk ;
MYPORT2 |= clkmsk ;
p>>=1;
}
}
}
MYPORT |= (1 << PIN_ENABLE) ; //
//MYPORT &= ~(1 << PIN_ENABLE) ;
// for(n=0;n<250;n++) asm ("nop");
}
SIGNAL(SIG_OUTPUT_COMPARE0)
{
static unsigned char plane = 0;
unsigned char row = 0;
switch (plane){
case 0:
OCR0 = 30;
break;
case 1:
OCR0 = 60;
break;
case 2:
OCR0 = 80;
break;
// case 3:
// OCR0 = 24;
// break;
// case 4:
// OCR0 = 48;
// break;
}
for(row=0;row<NUM_ROWS;row++){
rowshow(row, plane);
}
if(++plane==NUMPLANE) plane=0;
wdt_reset();
}
void timer0_on(){
/* TCCR0: FOC0 WGM00 COM01 COM00 WGM01 CS02 CS01 CS00
CS02 CS01 CS00
0 0 0 stop
0 0 1 clk
0 1 0 clk/8
0 1 1 clk/64
1 0 0 clk/256
1 0 1 clk/1024
*/
TCCR0 = 0x08 |0x04; // CTC Mode, clk/256 MH: slower 5 statt 4
TCNT0 = 0; // reset timer
OCR0 = 0x30; // Compare with this value 0x30
TIMSK = 0x02; // Compare match Interrupt on
}
void timer0_off(){
cli();
MYPORT &= ~(1 << PIN_ENABLE) ;
//MYPORT |= (1 << PIN_ENABLE) ; //hide
//COLPORT |= (1<<PIN_LINE_EN);//blank display
// PORTD |= 0x01;//blank display
TCCR0 = 0x00;
sei();
}
void watchdog_enable()
{
wdt_reset();
wdt_enable(0x00); // 17ms
}
void borg_hw_init(){
//COLPORT |= (1<<PIN_CLK) | (1<<PIN_LINE_EN);
//COLDDR |= (1<<PIN_CLK) | (1<<PIN_LINE_EN) | (1<<PIN_DATA);
//ROWDDR |= 0x07;
DDRA = 0xFF;
DDRC = 0xFF;
watchdog_enable();
timer0_on();
}

8
borg_hw/config.in

@ -11,7 +11,8 @@ int "Number of brightnes-levels" NUMPLANE 3
choice 'Hardware Driver' \ choice 'Hardware Driver' \
"Borg-16 HW_BORG_16 \ "Borg-16 HW_BORG_16 \
Andre-borg HW_BORG_ANDRE \ Andre-borg HW_BORG_ANDRE \
Laufschrift-borg HW_BORG_LS \ Laufschrift-borg HW_BORG_LS \
Laufschrift-borg-mh HW_BORG_MH \
Borg-mini HW_BORG_MINI" \ Borg-mini HW_BORG_MINI" \
'Borg-16' BORG_HW 'Borg-16' BORG_HW
@ -28,6 +29,11 @@ if [ "$BORG_HW" == "HW_BORG_LS" ] ; then
source borg_hw/config_borg_ls.in source borg_hw/config_borg_ls.in
fi fi
if [ "$BORG_HW" == "HW_BORG_MH" ] ; then
source borg_hw/config_borg_mh.in
fi
if [ "$BORG_HW" == "HW_BORG_MINI" ] ; then if [ "$BORG_HW" == "HW_BORG_MINI" ] ; then
source borg_hw/config_borg_mini.in source borg_hw/config_borg_mini.in
fi fi

45
borg_hw/config_borg_mh.in

@ -0,0 +1,45 @@
mainmenu_option next_comment
comment "MH Laufschrift-Borg port setup"
choice 'port for the 8 clock lines' \
"PORTA PORTA \
PORTB PORTB \
PORTC PORTC \
PORTD PORTD" \
'PORTA' CLOCKPORT
choice 'port for enable and data line' \
"PORTA PORTA \
PORTB PORTB \
PORTC PORTC \
PORTD PORTD" \
'PORTA' DATAPORT
comment "pin numbers for enable and data"
choice 'DATA Pin' \
"Pin0 0 \
Pin1 1 \
Pin2 2 \
Pin3 3 \
Pin4 4 \
Pin5 5 \
Pin6 6 \
Pin7 7" \
'Pin1' PIN_DATA
choice 'LINE_EN Pin' \
"Pin0 0 \
Pin1 1 \
Pin2 2 \
Pin3 3 \
Pin4 4 \
Pin5 5 \
Pin6 6 \
Pin7 7" \
'Pin0' PIN_ENABLE
endmenu

26
display_loop.c

@ -28,9 +28,9 @@ void display_loop(){
percnt_inc(); percnt_inc();
#endif #endif
mode = setjmp(newmode_jmpbuf); // mode = setjmp(newmode_jmpbuf);
oldOldmode = oldMode; oldOldmode = oldMode;
mode =0;
#ifdef JOYSTICK_SUPPORT #ifdef JOYSTICK_SUPPORT
waitForFire = 1; waitForFire = 1;
#endif #endif
@ -54,6 +54,10 @@ void display_loop(){
#ifdef ANIMATION_SPIRALE #ifdef ANIMATION_SPIRALE
case 2: case 2:
movinglines();
test_lines();
rectangles();
scrolltext("d/#ABC");
spirale(5); spirale(5);
break; break;
#endif #endif
@ -72,7 +76,7 @@ void display_loop(){
#ifdef ANIMATION_SCHACHBRETT #ifdef ANIMATION_SCHACHBRETT
case 5: case 5:
schachbrett(20); //schachbrett(10);
break; break;
#endif #endif
@ -101,22 +105,26 @@ void display_loop(){
#endif #endif
case 29: case 29:
mode = 1; // mode = 1;
break; break;
#ifdef ANIMATION_TESTS #ifdef ANIMATION_TESTS
case 31: case 31:
test_level1(); //test_level1();
break; break;
case 32: case 32:
test_level2(); //test_level2();
break; break;
case 33: case 33:
test_level3(); //test_level3();
break; break;
case 35: case 35:
test1(); test_palette();
while(1); test_palette2();
break; break;
#endif #endif

2
main.c

@ -5,7 +5,7 @@
#include "config.h" #include "config.h"
#include "borg_hw/borg_hw.h" #include "borg_hw/borg_hw.h"
#include "can/borg_can.h" // #include "can/borg_can.h"
#include "random/prng.h" #include "random/prng.h"
#include "random/persistentCounter.h" #include "random/persistentCounter.h"
#include "display_loop.h" #include "display_loop.h"

77
pixel.c

@ -33,6 +33,83 @@ void setpixel(pixel p, unsigned char value ){
pixmap[plane][0][pos]&=mask; pixmap[plane][0][pos]&=mask;
} }
void line(pixel p1, pixel p2 ,unsigned char value){
char dx, dy, stepx, stepy, fraction;
dy = p2.y - p1.y;
dx = p2.x - p1.x;
if ( dy < 0 )
{
dy = -dy;
stepy = -1;
}
else
{
stepy = 1;
}
if ( dx < 0 )
{
dx = -dx;
stepx = -1;
}
else
{
stepx = 1;
}
dx <<= 1;
dy <<= 1;
setpixel(p1 , value );
if ( dx > dy )
{
fraction = dy - (dx >> 1);
while ( p1.x != p2.x )
{
if ( fraction >= 0 )
{
p1.y += stepy;
fraction -= dx;
}
p1.x += stepx;
fraction += dy;
setpixel(p1 , value );
}
}
else
{
fraction = dx - (dy >> 1);
while ( p1.y != p2.y )
{
if ( fraction >= 0 )
{
p1.x += stepx;
fraction -= dy;
}
p1.y += stepy;
fraction += dx;
setpixel(p1 , value );
}
}
}
void filled_rectangle(pixel p1, unsigned char w, unsigned char h ,unsigned char value){
unsigned char y;
for (y=p1.y;y<=(p1.y+h);y++){
line((pixel){p1.x,y}, (pixel){(p1.x+w),y} ,value);
}
}
//shifts pixmap left. It is really shifted right, but because col0 is left in the Display it's left. //shifts pixmap left. It is really shifted right, but because col0 is left in the Display it's left.
void shift_pixmap_l(){ void shift_pixmap_l(){
unsigned char plane, row, byte; unsigned char plane, row, byte;

11
pixel.h

@ -26,6 +26,17 @@ void clear_screen(unsigned char value);
void setpixel(pixel p, unsigned char value); void setpixel(pixel p, unsigned char value);
#define clearpixel(p) setpixel(p, 0); #define clearpixel(p) setpixel(p, 0);
// straight or non straight line from one point to the other
// value=brightness
void line(pixel p1, pixel p2 ,unsigned char value);
// filled_rectangle p1=upper right corner, w=width, h=height ,
// value=brightness
void filled_rectangle(pixel p1, unsigned char w, unsigned char h ,unsigned char value);
unsigned char get_pixel(pixel p); unsigned char get_pixel(pixel p);
unsigned char get_next_pixel(pixel p, direction dir); unsigned char get_next_pixel(pixel p, direction dir);

4
scrolltext/config.in

@ -2,9 +2,9 @@
dep_bool_menu "Scrolltext Support" SCROLLTEXT_SUPPORT y dep_bool_menu "Scrolltext Support" SCROLLTEXT_SUPPORT y
choice 'Scrolltext Font' \ choice 'Scrolltext Font' \
'Arial_8 font_arial8 \ "Arial_8 font_arial8 \
Small_6 font_small6 \ Small_6 font_small6 \
Uni_53 font_uni53' \ Uni_53 font_uni53" \
'Arial_8' SCROLLTEXT_FONT 'Arial_8' SCROLLTEXT_FONT
int "Scrolltest buffer size" SCROLLTEXT_BUFFER_SIZE 128 int "Scrolltest buffer size" SCROLLTEXT_BUFFER_SIZE 128

2
scrolltext/scrolltext3.c

@ -14,7 +14,7 @@
#include "font_small6.h" #include "font_small6.h"
#include "font_uni53.h" #include "font_uni53.h"
#define MAX_FONTS 1 #define MAX_FONTS 3
font fonts[MAX_FONTS]; font fonts[MAX_FONTS];
#define MAX_SPECIALCOLORS 3 #define MAX_SPECIALCOLORS 3

Loading…
Cancel
Save