source: projects/bull-anelex-project/trunk/anelex-interface/src/anelex.c @ 63

Last change on this file since 63 was 63, checked in by sven, 9 years ago

Anelex-Interface: Finalized the Builtin memory text printing (which actually was a lot of work...).

File size: 2.8 KB
Line 
1/**
2 * ANELEX PRINTER Interface Microcontroller
3 *
4 * anelex.c: All communication related routines to the anelex device.
5 *
6 * This file is part of the Bull Anelex Project
7 * Copyright (C) 2010, 2011 Sven Köppel, technikum29.de
8 *
9 * This program is free software; you can redistribute
10 * it and/or modify it under the terms of the GNU General
11 * Public License as published by the Free Software
12 * Foundation; either version 3 of the License, or (at
13 * your option) any later version.
14 *
15 * This program is distributed in the hope that it will
16 * be useful, but WITHOUT ANY WARRANTY; without even the
17 * implied warranty of MERCHANTABILITY or FITNESS FOR A
18 * PARTICULAR PURPOSE. See the GNU General Public License
19 * for more details.
20 *
21 * You should have received a copy of the GNU General
22 * Public License along with this program; if not, see
23 * <http://www.gnu.org/licenses/>.
24 *
25 **/
26
27#include "toolchain.h"
28#include "anelex_code.h"
29#include "anelex.h"
30
31void print_line() {
32        // startup line printing
33        //puts("Starting line transmission");
34        current_line_cnt = 0;
35        print_line_feed();
36        line_state = LINE_TRANSMITTING;
37}
38
39
40void print_line_feed() {
41        // Lege Zeilenvorschub an (spaeter mal variabel)
42        set_data(0x01);
43        _delay_us(800);
44        start_strobe();
45        _delay_us(1);
46        stop_strobe();
47}
48
49
50ISR(INT2_vect) {
51        // Communication Announcement steigende Flanke.
52        // je nach zustand
53        if(line_state != LINE_TRANSMITTING)
54                return;
55
56        uint8_t current_counter = current_line_cnt; // volatile lokal holen, spaeter unnoetig
57
58        if(current_counter < LINE_LENGTH) {
59                // aussage: Naechsetes Zeichen kann angelegt werden
60                char orig = current_line[ current_counter ];
61                if(orig) {
62                        // normales zeichen
63                        char transformed = anelex_code[ orig ];
64                        //printf("%d: Zeichen %c, entspricht oktal %o\n", current_counter, orig, transformed);
65                        //printf("%d", current_counter, orig);
66                        //_delay_us(100);
67                       
68                        // LEGE ZEICHEN AN:
69                        set_data(transformed);
70                        _delay_us(20); 
71                        start_strobe();
72                        _delay_us(2);
73                        stop_strobe();
74                        // jetzt bis zum naechsten Zeichen warten
75
76                        current_line_cnt++;
77                        return;
78                }
79        }
80
81        // Zeilenende erreicht (etwa durch \0 oder zu grossen current_counter,
82        // was nicht vorkommen sollte)
83        line_state = LINE_PRINTING;
84        set_data(0x01); // aufraeumen am DATENPORT
85        //printf("Print Command\n");
86
87        start_printcmd();
88        _delay_us(10);
89        stop_printcmd();
90        // warten auf auf das naechste CA.
91}
92
93ISR(INT1_vect) {
94        // Rising Edge von Line Ready = Zeile wird gedruckt!
95        if(line_state != LINE_PRINTING)
96                return;
97
98        //printf("Zeile wird gedruckt...\n");
99        //puts("printing");
100        while(!is_ready()); // das ist jetzt ziemlicher ... quatsch
101        puts("line finished");
102        //printf("Zeile fertig gedruckt\n");
103
104        line_state = LINE_FINISHED;
105}
106
107
Note: See TracBrowser for help on using the repository browser.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License