Projekte
workwind
BGX1 firmware
display.c
Projekte
Forum
Doku
Öffentliche Projekte
Startseite
Beispielprogramme
Projekte von anderen
Welcome
Username
Passwort
Eingeloggt bleiben
Zugangsdaten vergessen?
Registrieren
Projektverwaltung
⇨ Please choose! ⇦
——————————————————
✎ Create new project...
★ Browse existing projects...
——————————————————
⚬ MotorTest#1
⚬ C Tutorial 8#1
⚬ NIBO2 C Project#1
⚙ C Tutorial 15#1
⚬ 2010_11_18_el_test001#1
BGX1 firmware
adc.c
adc.h
battery.xbm
bgx1_protocol.h
Biene.xbm
display.c
display.h
exclamation.xbm
gfx.c
gfx.h
i2c.c
i2c.h
i2cconf.h
images.c
images.h
iodefs.h
iodefs_bgx1.h
main.c
MarsRover.xbm
Nase.xbm
nicai_logo.xbm
pwm.c
pwm.h
question.xbm
smily1.xbm
smily2.xbm
Project details
Compiler settings
Nachrichten
Sie sind nicht eingeloggt.
Neuigkeiten
★
NiboRoboLib 3.6
2017-01-17: Neue Version 3.6
★
NiboRoboLib 3.4.1
2016-04-16: Neue Version 3.4.1
★
Coding Tutorial
2015-11-22: Jetzt auch für den NIBO burger!
Site-Statistic
7433 private projects
378 public projects
16180353 lines compiled
58212 builds
NIBO
@
bgx1_firmware/display.c [read only]
/* BSD-License: Copyright (c) 2010 by Nils Springob, nicai-systems, Germany All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name nicai-systems nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /*! * @brief Routinen zur Displaysteuerung * @author Nils Springob (nils@nicai-systems.de) * @date 2010-03-28 */ #include "iodefs.h" #include "display.h" #include <util/delay.h> #ifdef __cplusplus extern "C" { #endif /*! Puffergroesse fuer eine Zeile in bytes */ #define DISPLAY_BUFFER_SIZE (DISPLAY_LENGTH + 1) #define DISPLAY_CLEAR 0x01 /*!< Kommando zum Löschen */ #define DISPLAY_CURSORHOME 0x02 /*!< Kommando für den Cursor */ /**! Output-Pins des Displays */ #define DISPLAY_OUT (_BV(IO_DISPLAY_RS_BIT)|_BV(IO_DISPLAY_RW_BIT)|_BV(IO_DISPLAY_EN_BIT)) /**! Input-Pins des Displays */ #define DISPLAY_IN (_BV(IO_DISPLAY_READY_BIT)) #define display_acquire() do {set_output_bit(IO_KEY);} while(0) #define display_release() do {IO_DISPLAY_PORT = io_port_x; IO_DISPLAY_DDR = io_ddr_x; clear_output_bit(IO_KEY);} while(0) volatile uint8_t io_port_x; volatile uint8_t io_ddr_x; uint8_t display_type; void display_update_alt() { display_release(); } uint8_t display_init(){ display_type=0xff; display_acquire(); activate_output_bit(IO_DISPLAY_RS); activate_output_bit(IO_DISPLAY_RW); activate_output_bit(IO_DISPLAY_EN); activate_output_bit(IO_DISPLAY_CS1); activate_output_bit(IO_DISPLAY_CS2); activate_output_bit(IO_DISPLAY_RST); IO_DISPLAY_DDR = 0x00; clear_output_bit(IO_DISPLAY_RS); clear_output_bit(IO_DISPLAY_RW); clear_output_bit(IO_DISPLAY_EN); clear_output_bit(IO_DISPLAY_CS1); clear_output_bit(IO_DISPLAY_CS2); clear_output_bit(IO_DISPLAY_RST); _delay_ms(1); set_output_bit(IO_DISPLAY_RST); deactivate_output_bit(IO_DISPLAY_RST); // pull up only if (display_wait(0)) { if (display_wait(1)) display_type=2; else display_type=1; } if (display_type==0xff) display_type=0; display_release(); return display_type; } void display_write(uint8_t mode, uint8_t data){ display_acquire(); set_output_bitval(IO_DISPLAY_CS1, !(mode&0x01)); set_output_bitval(IO_DISPLAY_CS2, mode&0x01); set_output_bitval(IO_DISPLAY_RS, mode&0x02); clear_output_bit(IO_DISPLAY_RW); IO_DISPLAY_DDR = 0xff; IO_DISPLAY_PORT = data; _delay_us(1); set_output_bit(IO_DISPLAY_EN); _delay_us(1); clear_output_bit(IO_DISPLAY_EN); _delay_us(1); // IO_DISPLAY_PORT = 0x00; // IO_DISPLAY_DDR = 0x00; display_release(); } uint8_t display_read(uint8_t mode){ display_acquire(); set_output_bitval(IO_DISPLAY_CS1, !(mode&0x01)); set_output_bitval(IO_DISPLAY_CS2, mode&0x01); set_output_bitval(IO_DISPLAY_RS, mode&0x02); set_output_bit(IO_DISPLAY_RW); IO_DISPLAY_DDR = 0x00; _delay_us(1); set_output_bit(IO_DISPLAY_EN); _delay_us(4); uint8_t data = IO_DISPLAY_PIN; clear_output_bit(IO_DISPLAY_EN); _delay_us(1); display_release(); return data; } // high level fuctions uint8_t display_wait(uint8_t mode){ if (display_type==0) return 0; mode &= 0x01; uint16_t timeout=0xffff; while (timeout--){ if ((display_read(mode)&0x80)==0x00) return 1; } return 0; } #ifdef __cplusplus } // extern "C" #endif
Compiler results:
Werbung
Online
lincolngreenwood0
Victorepo
Victorlnh
warrenhinder6456