2024年3月5日 星期二

Python Tkinter First Example

import tkinter as tk


def on_closing():

    root.destroy()


class MainWindow(tk.Tk):

    def __init__(self, *args, **kwargs):

        tk.Tk.__init__(self, *args, **kwargs)


root = MainWindow()

root.title('Main Window')

root.protocol("WM_DELETE_WINDOW", on_closing)

root.geometry('640x480')

root.mainloop()

 

2024年3月4日 星期一

在Ubuntu桌面載入後自動執行程式

在 <home>/.config 新增 autostart 目錄

touch <home>/.config/autostart/<program name>.desktop

在<program name>.desktop加入以下內容

[Desktop Entry]

Name=<program name>

Exec=<path to>/<your program execuable>

Type=application

 就可以了

RaspberryPi也一樣可以這樣處理

2024年2月17日 星期六

 首先到 mbed online IDE

https://ide.mbed.com/compiler/

第一次使用經過註冊程序就會看到IDE畫面



接著開始新增專案 mbed沒有提供STM32F4 DISC1版本

但是 Seeed Arch Max 剛好是使用 STMD32F407 這顆 MCU

所以選取 Seeed Arch Max 當作專案 platform

專案 template 選取 Blinky LED Hello World

程式碼修改如下:

#include "mbed.h"

#define BLINKING_RATE     500

int main()
{
    // Initialise PD12 as an output
    DigitalOut gLED(PD_12);
    
    while (true) {
        gLED = !gLED;
        ThisThread::sleep_for(BLINKING_RATE);
    }
}

按下介面上的 Compile 按鈕

mbed online IDE 會在完成後跳出下載 binary 檔案

將這個 .bin 檔存入 STM32F4 DISC1 的資料夾

最後就會看到 PD12 開始閃爍囉!

Reference

https://www.hackster.io/PSoC_Rocks/easy-programming-stm32f407-discovery-board-with-mbed-8ead8e

在AWS EC2上安裝WordPress

環境: Ubuntu 18.04 Server

第一次登入EC2後

  1. sudo apt update
  2. sudo apt install apache2
  3. sudo add-apt-repository ppa:ondrej/php
  4. sudo apt update
  5. sudo apt install php7.4
  6. sudo apt install mysql-server
  7. sudo apt install php7.4-mysql

以上完成wordpress需要的軟體。

在使用mysql server前先進行初始化。

  1. mysql_secure_installation
  2. 設定root密碼及刪除不必要的使用者帳號
  3. sudo mysql
mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';

將原本root的登入方式(auth_socket)改為mysql_native_password

mysql> CREATE DATABASE new_db;
mysql> CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON new_db.* TO 'new_user'@'localhost';

建立wordpress的資料庫(new_db)並設定資料庫權限給新建的使用者帳戶(new_user),之後wordpress安裝時需要輸入此使用者帳戶及密碼。

接下來到wordpress.org下載最新版本(目前為5.5.1)的wordpress

% cd /var/www/html
% sudo unzip wordpress-5.5.1.zip
% sudo chown -R www-data. wordpress/

最後打開AWS EC2的security group的port 80

連入網站即可開始進行wordpress的最後設定。

Linux Read-only file system

 常用的解決方法

sudo mount -o remount,rw /

在respberry pi如果出現PARTUUID=xxx Error
可以將指令改成
sudo mount -o remount,rw /dev/mmcblk0p2 /

Ubuntu install RTL8188 Wifi Usb Adapter Driver

 Download driver from:

https://github.com/ulli-kroll/rtl8188fu

After ‘make’:

sudo modprobe cfg80211
sudo insmod rtl8188fu.ko

Connect to AP:
nmcli r wifi on
nmcli d wifi list
nmcli d wifi connect “ssid” password “pw”

gradle exception

 我在下指令 gradlew signingReport 時, 出現了這個錯誤

error occurred during initialization of vm could not reserve enough space for 1572864kb object heap

原來我安裝到了 32bit 版本的 JDK

所以 allocate 過大的 heap size 會出現問題

解決的方法當然是改成安裝 64bit JDK 或者如果是用 Android Studio 的

可以在 gradle.properties 檔修改成

org.gradle.jvmargs=-Xmx512M

就可以了

PS. 如果下指令 java -d32 -version 會正常出現版本說明的話 那就是安裝到 32bit JDK

Python Tkinter First Example

import tkinter as tk def on_closing():     root.destroy() class MainWindow(tk.Tk):     def __init__(self, *args, **kwargs):         tk.Tk.__...