Skip to main content

Posts

[GTK] Example of using GtkBox with label and button

[1]Source code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 #include <gtk/gtk.h> void on_window_closed (GtkWidget * window, gpointer data) { gtk_main_quit(); } static void destroy (GtkWidget * widget, gpointer data) { gtk_main_quit(); } static void button_clicked (GtkWidget * button, gpointer data) { g_print( "Button clicked \n " ); } int main ( int argc, char * argv[]) { GtkWidget * window, * label, * box, * button ; gtk_init( & argc, & argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW (window), "Test GTK" ); gtk_window_set_default_size (GTK_WINDOW (window), 500 , 200 ); #if 1 //Use gtk3: change 0->1, Use gtk2: keep it is 0 //Using gtk3 box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5 ); ...

[C++] One way to convert pointer of structure to vector

Of course, you can choose one method of C++ likes reinterpret which is described in below topic: https://www.geeksforgeeks.org/reinterpret_cast-in-c-type-casting-operators/ However, it is easily to find out one big problem in here is: reinterpret_cast is a very special and dangerous type of casting operator In embedded system, this problem is not allowed. Then, we should convert it by manually. The idea is, you push each structure to vector by passing number of structure to function which is used for converting. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 #include <iostream> #include <list> #include <vector> #include <string.h> using namespace std; #define STR_NUM 3 //Number of structures typedef struct { char text_id[ 16 ]; char name[ 16 ]; }st_A; /* Show vector dat...

What are some best practices for reducing memory usage in C?

Thiếu memory khi lập trình Arduino và cách giải quyết. Lacking memory with Arduino program. Đây là một số gợi ý để giải quyết nếu bạn đã từng thấy warning dưới: Have you ever seen any below warning? - Low memory available, stability problems may occur. - Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint. If the answer is YES, i would like to suggest some solutions for saving memory in this articles. Các nguyên nhân: Some root causes: 1. Khai báo biến local tràn lan. 2. Dùng hàm lcd.print or serial.print tùy tiện. 3. Cấp phát động tùy tiện, ko tính toán kỹ lưỡng số lượng phần từ trong mảng cần dùng. .... Một số gợi ý để tiết kiệm memory  Some suggestions to save memory. - Sử dụng một số kỹ thuật như #pragma pack(), union, bit field, cấp phát động.             Using some C technique #pragma pack(), union, bit field, dynamic memory al...

[IoT] Common Sensor List

Common Sensor List

[Bài tổng hợp] Các bước chuẩn bị để quay phim bằng mobile như dân chuyên nghiệp

Cài đặt phần mềm Cài Open Camera (cho Android), dùng ứng dụng này quay phim thay vì sử dụng phần mềm mặc định của máy. - Thử dùng các chế độ lấy nét khác nhau. Chỉnh cấu hình (setting) phù hợp: 1080p/60fps hoặc 720p/60 fps Thứ tự chuẩn bị khi quay 1. Giải phóng bộ nhớ máy. 2. Sạc pin đầy đủ. 3. Đặt máy quay theo hướng ngang màn hình 4. Thiết lập cấu hình phần mêm quay ( frame rate, tắt lấy nét tự động, điều chỉnh sáng tối cho phù hợp) 5. Lau sạch ống kính 6. Bắt đầu quay Kỹ thuật quay phim cơ  bản 1. Ánh sáng ổn định. Dùng phần mềm quay phim chuyên dụng để căn chỉnh trước Tránh quay các cảnh quá tối or quá sáng ko thực sự cần thiết. 2. Giữ điện thoại ổn định khi quay (Chống rung) Mẹo - Chống rung bằng "cơm" ( Tư thế tay, tư thế di chuyển) - Chống rung bằng phần mềm - Chống rung bằng gimbal Tham khảo:  https://www.youtube.com/watch?v=b88XGvzwcoE 3. Âm thanh hiện trường 4. Không dùng digital zoom 5. Luôn quay video theo hướng nga...

Ubuntu troubles

Problem #1 Using winscp to transfer file from windows machine to Ubuntu It show error: "The server rejected SFTP connection, but it listens for FTP connections." Solution: 1. To install it, open terminal (Ctrl+Alt+T) or log in Ubuntu server and run command: sudo apt-get install openssh-server 2. After that, you should have SSH service enabled in your system, you may check its status by running command: sudo service ssh status Problem #2 Can I add a shortcut to replace a path in Linux? Solution https://askubuntu.com/questions/58814/how-do-i-add-environment-variables vi ~/.bashrc  add below line to end of file .bashrc export MTRUMPY_SRC=/home/thaidao/work/project/mTrumpy/src source ~/.bashrc When you want to go directory MTRUMPY_SRC, just type "cd $MTRUMPY_SRC" https://stackoverflow.com/questions/862966/hide-all-notmatching-lines-in-vim Problem #3 SVN command in use Get latest commit from remote server svn update ...

Make your song engine

HOW TO MAKE YOUR SONG Imagine, one software or mobile appication allows you create own song from your name, is it great? Procedure looks likes: You type your name in one text box. Hidden engine will convert your name to musical note. Basically, your name can be presented by each ASCII characters which is 8 bit in computer science. Other hand, everyone know  Do–Re–Mi–Fa–Sol–La–Si -Do, it also 8. Simply, just mapping one-one from your word characters to musical note and mixed them with your favourite song. Example: Input is Mr President Trump Output is 2 part:  1. Trump Musical sheet 2. Trump musical song ( may be National song :D) You can feel free share them to your friend, or use it likes your signature style or any personalize crazy idea. Hopefully, some geek makes it become real one day. That time, I would like to become a first tester who verify quality of this funny software.