Keep "astyled" elements in ultralcd-related files

This commit is contained in:
Scott Lahteine
2015-10-02 23:11:05 -07:00
parent b90ec2cf8f
commit 2016ed48c0
4 changed files with 288 additions and 297 deletions

View File

@@ -1497,6 +1497,7 @@ static void menu_action_setting_edit_callback_bool(const char* pstr, bool* ptr,
/** LCD API **/ /** LCD API **/
void lcd_init() { void lcd_init() {
lcd_implementation_init(); lcd_implementation_init();
#if ENABLED(NEWPANEL) #if ENABLED(NEWPANEL)
@@ -1505,10 +1506,12 @@ void lcd_init() {
SET_INPUT(BTN_EN2); SET_INPUT(BTN_EN2);
WRITE(BTN_EN1, HIGH); WRITE(BTN_EN1, HIGH);
WRITE(BTN_EN2, HIGH); WRITE(BTN_EN2, HIGH);
#if BTN_ENC > 0 #if BTN_ENC > 0
SET_INPUT(BTN_ENC); SET_INPUT(BTN_ENC);
WRITE(BTN_ENC, HIGH); WRITE(BTN_ENC, HIGH);
#endif #endif
#if ENABLED(REPRAPWORLD_KEYPAD) #if ENABLED(REPRAPWORLD_KEYPAD)
pinMode(SHIFT_CLK, OUTPUT); pinMode(SHIFT_CLK, OUTPUT);
pinMode(SHIFT_LD, OUTPUT); pinMode(SHIFT_LD, OUTPUT);
@@ -1516,7 +1519,9 @@ void lcd_init() {
WRITE(SHIFT_OUT, HIGH); WRITE(SHIFT_OUT, HIGH);
WRITE(SHIFT_LD, HIGH); WRITE(SHIFT_LD, HIGH);
#endif #endif
#else // Not NEWPANEL #else // Not NEWPANEL
#if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register #if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register
pinMode(SR_DATA_PIN, OUTPUT); pinMode(SR_DATA_PIN, OUTPUT);
pinMode(SR_CLK_PIN, OUTPUT); pinMode(SR_CLK_PIN, OUTPUT);
@@ -1529,6 +1534,7 @@ void lcd_init() {
WRITE(SHIFT_LD, HIGH); WRITE(SHIFT_LD, HIGH);
WRITE(SHIFT_EN, LOW); WRITE(SHIFT_EN, LOW);
#endif // SR_LCD_2W_NL #endif // SR_LCD_2W_NL
#endif//!NEWPANEL #endif//!NEWPANEL
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
@@ -1967,7 +1973,6 @@ char *ftostr43(const float &x) {
// Convert float to string with 1.23 format // Convert float to string with 1.23 format
char* ftostr12ns(const float& x) { char* ftostr12ns(const float& x) {
long xx = x * 100; long xx = x * 100;
xx = abs(xx); xx = abs(xx);
conv[0] = (xx / 100) % 10 + '0'; conv[0] = (xx / 100) % 10 + '0';
conv[1] = '.'; conv[1] = '.';
@@ -1981,7 +1986,6 @@ char *ftostr12ns(const float &x) {
char* ftostr32sp(const float& x) { char* ftostr32sp(const float& x) {
long xx = abs(x * 100); long xx = abs(x * 100);
uint8_t dig; uint8_t dig;
if (x < 0) { // negative val = -_0 if (x < 0) { // negative val = -_0
conv[0] = '-'; conv[0] = '-';
dig = (xx / 1000) % 10; dig = (xx / 1000) % 10;

View File

@@ -420,7 +420,7 @@ unsigned lcd_print(char c) { return charset_mapper(c); }
lcd_print(' '); lcd_print(' ');
} }
// scrol the PSTR'text' in a 'len' wide field for 'time' milliseconds at position col,line // Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line
void lcd_scroll(int col, int line, const char* text, int len, int time) { void lcd_scroll(int col, int line, const char* text, int len, int time) {
char tmp[LCD_WIDTH + 1] = {0}; char tmp[LCD_WIDTH + 1] = {0};
int n = max(lcd_strlen_P(text) - len, 0); int n = max(lcd_strlen_P(text) - len, 0);

View File

@@ -21,11 +21,9 @@
#include <U8glib.h> #include <U8glib.h>
static void ST7920_SWSPI_SND_8BIT(uint8_t val) static void ST7920_SWSPI_SND_8BIT(uint8_t val) {
{
uint8_t i; uint8_t i;
for( i=0; i<8; i++ ) for (i = 0; i < 8; i++) {
{
WRITE(ST7920_CLK_PIN,0); WRITE(ST7920_CLK_PIN,0);
#if F_CPU == 20000000 #if F_CPU == 20000000
__asm__("nop\n\t"); __asm__("nop\n\t");
@@ -46,13 +44,10 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val)
#define ST7920_WRITE_BYTE(a) {ST7920_SWSPI_SND_8BIT((uint8_t)((a)&0xf0u));ST7920_SWSPI_SND_8BIT((uint8_t)((a)<<4u));u8g_10MicroDelay();} #define ST7920_WRITE_BYTE(a) {ST7920_SWSPI_SND_8BIT((uint8_t)((a)&0xf0u));ST7920_SWSPI_SND_8BIT((uint8_t)((a)<<4u));u8g_10MicroDelay();}
#define ST7920_WRITE_BYTES(p,l) {uint8_t i;for(i=0;i<l;i++){ST7920_SWSPI_SND_8BIT(*p&0xf0);ST7920_SWSPI_SND_8BIT(*p<<4);p++;}u8g_10MicroDelay();} #define ST7920_WRITE_BYTES(p,l) {uint8_t i;for(i=0;i<l;i++){ST7920_SWSPI_SND_8BIT(*p&0xf0);ST7920_SWSPI_SND_8BIT(*p<<4);p++;}u8g_10MicroDelay();}
uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) {
{
uint8_t i, y; uint8_t i, y;
switch(msg) switch (msg) {
{ case U8G_DEV_MSG_INIT: {
case U8G_DEV_MSG_INIT:
{
OUT_WRITE(ST7920_CS_PIN, LOW); OUT_WRITE(ST7920_CS_PIN, LOW);
OUT_WRITE(ST7920_DAT_PIN, LOW); OUT_WRITE(ST7920_DAT_PIN, LOW);
OUT_WRITE(ST7920_CLK_PIN, HIGH); OUT_WRITE(ST7920_CLK_PIN, HIGH);
@@ -64,8 +59,7 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
ST7920_WRITE_BYTE(0x01); //clear CGRAM ram ST7920_WRITE_BYTE(0x01); //clear CGRAM ram
u8g_Delay(15); //delay for CGRAM clear u8g_Delay(15); //delay for CGRAM clear
ST7920_WRITE_BYTE(0x3E); //extended mode + GDRAM active ST7920_WRITE_BYTE(0x3E); //extended mode + GDRAM active
for(y=0;y<LCD_PIXEL_HEIGHT/2;y++) //clear GDRAM for (y = 0; y < LCD_PIXEL_HEIGHT / 2; y++) { //clear GDRAM
{
ST7920_WRITE_BYTE(0x80 | y); //set y ST7920_WRITE_BYTE(0x80 | y); //set y
ST7920_WRITE_BYTE(0x80); //set x = 0 ST7920_WRITE_BYTE(0x80); //set x = 0
ST7920_SET_DAT(); ST7920_SET_DAT();
@@ -77,31 +71,25 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
ST7920_NCS(); ST7920_NCS();
} }
break; break;
case U8G_DEV_MSG_STOP: case U8G_DEV_MSG_STOP:
break; break;
case U8G_DEV_MSG_PAGE_NEXT: case U8G_DEV_MSG_PAGE_NEXT: {
{
uint8_t* ptr; uint8_t* ptr;
u8g_pb_t* pb = (u8g_pb_t*)(dev->dev_mem); u8g_pb_t* pb = (u8g_pb_t*)(dev->dev_mem);
y = pb->p.page_y0; y = pb->p.page_y0;
ptr = (uint8_t*)pb->buf; ptr = (uint8_t*)pb->buf;
ST7920_CS(); ST7920_CS();
for( i = 0; i < PAGE_HEIGHT; i ++ ) for (i = 0; i < PAGE_HEIGHT; i ++) {
{
ST7920_SET_CMD(); ST7920_SET_CMD();
if ( y < 32 ) if (y < 32) {
{
ST7920_WRITE_BYTE(0x80 | y); //y ST7920_WRITE_BYTE(0x80 | y); //y
ST7920_WRITE_BYTE(0x80); //x=0 ST7920_WRITE_BYTE(0x80); //x=0
} }
else else {
{
ST7920_WRITE_BYTE(0x80 | (y - 32)); //y ST7920_WRITE_BYTE(0x80 | (y - 32)); //y
ST7920_WRITE_BYTE(0x80 | 8); //x=64 ST7920_WRITE_BYTE(0x80 | 8); //x=64
} }
ST7920_SET_DAT(); ST7920_SET_DAT();
ST7920_WRITE_BYTES(ptr, LCD_PIXEL_WIDTH / 8); //ptr is incremented inside of macro ST7920_WRITE_BYTES(ptr, LCD_PIXEL_WIDTH / 8); //ptr is incremented inside of macro
y++; y++;
@@ -123,8 +111,7 @@ uint8_t u8g_dev_st7920_128x64_rrd_buf[LCD_PIXEL_WIDTH*(PAGE_HEIGHT/8)] U8G_NOC
u8g_pb_t u8g_dev_st7920_128x64_rrd_pb = {{PAGE_HEIGHT, LCD_PIXEL_HEIGHT, 0, 0, 0}, LCD_PIXEL_WIDTH, u8g_dev_st7920_128x64_rrd_buf}; u8g_pb_t u8g_dev_st7920_128x64_rrd_pb = {{PAGE_HEIGHT, LCD_PIXEL_HEIGHT, 0, 0, 0}, LCD_PIXEL_WIDTH, u8g_dev_st7920_128x64_rrd_buf};
u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn, &u8g_dev_st7920_128x64_rrd_pb, &u8g_com_null_fn}; u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn, &u8g_dev_st7920_128x64_rrd_pb, &u8g_com_null_fn};
class U8GLIB_ST7920_128X64_RRD : public U8GLIB class U8GLIB_ST7920_128X64_RRD : public U8GLIB {
{
public: public:
U8GLIB_ST7920_128X64_RRD(uint8_t dummy) : U8GLIB(&u8g_dev_st7920_128x64_rrd_sw_spi) {} U8GLIB_ST7920_128X64_RRD(uint8_t dummy) : U8GLIB(&u8g_dev_st7920_128x64_rrd_sw_spi) {}
}; };