[英]What unicode characters are best for drawing a squarewave in a string
我試圖從存儲的 GPIO 事件和時序數組中用字符串表示方波脈沖序列。 該代碼正在運行,但我需要更好的 Unicode 個字符來進行轉換。
這是我目前的方法
public String waveform()
{
String s = "";
int pulses;
int pulseWidth;
pulseWidth = events.get(1).duration; //mostly right!
for (RF433Event e: events)
{
pulses = e.duration/pulseWidth;
if (e.gpioEvent.getEdge() == PinEdge.RISING)
{
// rising edge so for the duration it was low
for (int i = 0; i<pulses; i++) s = s+'_';
s = s+"\u02E9";
} else
{
// falling edge so for the duration it was high
for (int i = 0; i<pulses; i++) s = s+"\u0305";
s = s+"\u02E5";
}
}
return s;
}
output 在 Intellij 控制台中看起來像這樣 window
但奇怪的是沒有出現在樹莓派上,我需要在樹莓派上安裝其他東西嗎?
經過大量的實驗,這對我有用
public String waveform()
{
String s = "";
int pulses;
int pulseWidth;
// Characters tried for drawing the pulse train
// Low line - "_", "\u0332" Combining Low Line, "\uFF3F"; FULLWIDTH LOW LINE
// High line - "\u0305" COMBINING OVERLINE, "\u203E" over line
// Vertical - "\u20D2" COMBINING LONG VERTICAL LINE OVERLAY, "\u007C" Vertical line, "\u02E9" MODIFIER LETTER EXTRA-LOW TONE BAR
if (events.get(0).duration > 50000) {return "Excessive duration in pluse 0 "+events.get(0).duration;}
pulseWidth = 100; //gives a reasonable pulse train
for (RF433Event e: events)
{
pulses = e.duration/pulseWidth;
if (e.gpioEvent.getEdge() == PinEdge.RISING)
{
// rising edge so for the duration it was low
for (int i = 0; i<pulses; i++) s = s+ "_";
s = s+"\u20D2";
} else
{
// falling edge so for the duration it was high
for (int i = 0; i<pulses; i++) s = s+"\u0305";
s = s+"\u20D2";
}
}
return s;
}
我喜歡使用“組合字符”的想法,但發現它們更難編輯。 這是我使用或嘗試過的其他 unicode 選項。
1 ┌────┐ ┏━━━━┓
0 ──┘ └── ━━┛ ┗━━
▁▆▆▆▁▁▇▇▁▁
▁▆▆▆▁▁▇▇▁▁
⎺⎺⎺⎺⎺\⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽/⎺⎺⎺⎺⎺\⎽⎽
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.