libmoglk libMoGlk
A library to drive Matrix Orbital's GLK graphic LCD

Browse the code

Differences between 36 and 37 on /.
Number of edited files: 11 (6 added, 2 deleted and 3 modified)
Author: ematech
Log message: Tried to use GNU common c++ instead of termios for portability (Still needs a lot of work)
Switched from Makefiles to waf for the main library
Date: 2010-06-23 09:57:37

Added file(s) Deleted file(s) Modified file(s)

 

Old New Code
24 24
all: display
25 25

                                        
26 26
display: display.cc
27  
	$(CC) $(CFLAGS) -I../../src -L../../src display.cc -lmoglk -o display
  27
	$(CC) $(CFLAGS) -I../../src -L../../src display.cc -lmoglk -o display -lccgnu2 -lrt -pthread -lpthread -ldl -L/lib
28 28

                                        
29 29
clean:
30 30
	rm display
31 31

                                        

 

Old New Code
29 29
		return -1;
30 30
	}
31 31
	char port[] = "/dev/ttyUSB0";
32  
	unsigned long int speed = 19200;
33 32

                                        
34  
	moglk lcd;
35  
	int check = lcd.init(port,speed);
36  
	if (!check)
37  
	{
38  
		lcd.display(argv[1],1,0,0);
39  
		//lcd.display("\n",1);
40  
	}
41  
	else
42  
	{
43  
	        std::cerr << "libmoglk exited with code " << check << std::endl;
44  
		return -1;
45  
	}
  33
	Moglk *lcd;
  34
	lcd = new Moglk(port);
  35
		lcd->display(argv[1],1,0,0);
46 36
	return 0;
47 37
}
48 38

                                        

 

Old New Code
553 553
#define RET_LK404_25					0x73 //Done
554 554
#define RET_VK404_25					0x74 //Done
555 555

                                        
556  
//Includes
  556
// Headers
  557
// C++ headers
  558
#include <cstring>      // ISO C99 String handling
  559
#include <cstdio>	// C++ standard IO
  560
#include <iostream>     // C++ input output stream
  561
#include <sstream>      // C++ string stream
557 562
#include <bitset>       // C++ bit structure
558  
//#include <cc++/common.h>//GNU Common C++
559 563

                                        
  564
#include "port.h"
  565

                                    
560 566
//Namespaces
561 567
#ifdef	CCXX_NAMESPACES
562 568
using namespace std;
563 569
using namespace ost;
564 570
#endif
565 571

                                        
566  
// Class definition
  572
// Class definitions
567 573
class Moglk
568 574
{
569  
	private:
570  
        bool openPort(char * device_ptr = "/dev/ttyS0");
571  
        void configurePort(void);
572  
        void setPortBaudRate(unsigned long int baud_rate);
573  
        void setPortFlowControl(bool state);
574  

                                    
575  
        void transmit(int * data_ptr);
576  
        bool receive(unsigned char * data_ptr);
577  
        bool receiveFile(int * file_ptr);
578  

                                    
579  
        bool upload(char * data_ptr);
580  

                                    
581  
	void send(int * message_ptr);
582  

                                    
583 575
	public:
584  
        Moglk();
  576
        Moglk(const char * device_ptr = "/dev/ttyS0");
585 577
        ~Moglk();
586 578

                                        
587  
        bool init(char * device_ptr = "/dev/ttyS0",
588  
                  unsigned long int baud_rate = 0);
589  

                                    
590 579
        //int autodetect(void);
591 580

                                        
592 581
        //int autodetectPort(void);
593 582

                                        
594  
        unsigned long int autodetectBaudRate(char * device_ptr = "/dev/ttyS0");
595  

                                    
596 583
        bool setBaudRate(unsigned long int baud_rate = 19200);
597 584

                                        
598 585
        void setFlowControl(bool state = 0,
779 766
        void uploadFs(unsigned int size,
780 767
                      char * data_ptr);
781 768

                                        
  769
	private:
  770
	Port *serial_port;
  771
        unsigned long int autodetectBaudRate(char * device_ptr = "/dev/ttyS0");
  772
        void transmit(int * data_ptr);
  773
        bool receive(unsigned char * data_ptr);
  774
        bool receiveFile(int * file_ptr);
  775

                                    
  776
        bool upload(char * data_ptr);
  777

                                    
  778
	void send(int * message_ptr);
  779

                                    
782 780
}; /* Moglk */
783 781

                                        
784 782
#endif /* #ifndef _MOGLK_H */
785 783