wxStaticBoxSizer's label truncated on gui startup - wxwidgets

I'm having trouble showing the wxStaticBoxSizer label complete on my GUI startup, this is the important code:
wxFrame(NULL, wxID_ANY, title) ...
const int BORDER_WIDTH = 10;
wxBoxSizer* frameSizer = new wxBoxSizer(wxVERTICAL);
wxPanel *mainPanel = new wxPanel(this, wxID_ANY);
wxBoxSizer* mainSizer = new wxBoxSizer(wxHORIZONTAL);
wxStaticBoxSizer* sbSizerConf = new wxStaticBoxSizer(wxVERTICAL, mainPanel, _("Configuration"));
m_sb_panel = new wxPanel(sbSizerConf->GetStaticBox());
wxBoxSizer* miniSizer = new wxBoxSizer(wxVERTICAL);
m_notify_check = new wxCheckBox(m_sb_panel, wxID_ANY, _("Enable notifications"));
m_notify_check->SetValue(true);
m_sound_check = new wxCheckBox(m_sb_panel, wxID_ANY, _("Enable sound alarm"));
m_sound_check->SetValue(true);
m_front_check = new wxCheckBox(m_sb_panel, wxID_ANY, _("Show main window at timeout"));
m_front_check->SetValue(true);
wxSlider *m_min_slider = new wxSlider(m_sb_panel, wxID_ANY, 0, 0, 120, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS|wxSL_HORIZONTAL|wxSL_LABELS);
m_min_slider->SetToolTip(_("Minute value"));
wxSlider *m_sec_slider = new wxSlider(m_sb_panel, wxID_ANY, 0, 0, 59, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS|wxSL_HORIZONTAL|wxSL_LABELS);
m_sec_slider->SetToolTip(_("Second value"));
m_action_button = new wxButton(sbSizerConf->GetStaticBox(), ID_ACTION_BUTTON, _("&Start"));
m_action_button->Enable(false);
//
wxBoxSizer* RightSizer = new wxBoxSizer(wxVERTICAL);
wxStaticBoxSizer* sbSizerDisplay = new wxStaticBoxSizer(wxVERTICAL, mainPanel, _("Display"));
m_time_label = new wxStaticText(sbSizerDisplay->GetStaticBox(), wxID_ANY, _("00:00"));
wxStaticBoxSizer* sbSizerMsg = new wxStaticBoxSizer(wxVERTICAL, mainPanel, _("A message to remember"));
wxTextCtrl* m_textCtrl1 = new wxTextCtrl(sbSizerMsg->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxTE_MULTILINE);
miniSizer->Add(m_notify_check, 0, wxALL|wxEXPAND, BORDER_WIDTH);
miniSizer->Add(m_sound_check, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, BORDER_WIDTH);
miniSizer->Add(m_front_check, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, BORDER_WIDTH);
miniSizer->Add(m_min_slider, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, BORDER_WIDTH);
miniSizer->Add(m_sec_slider, 0, wxLEFT|wxRIGHT|wxEXPAND, BORDER_WIDTH);
m_sb_panel->SetSizer(miniSizer);
sbSizerConf->Add(m_sb_panel, 0, wxLEFT|wxRIGHT|wxBOTTOM, BORDER_WIDTH);
sbSizerConf->Add(m_action_button, 0, wxLEFT|wxRIGHT|wxBOTTOM, BORDER_WIDTH);
mainSizer->Add(sbSizerConf, 0, wxALL|wxEXPAND, 0);
sbSizerDisplay->Add(m_time_label, 0, wxALL|wxEXPAND, BORDER_WIDTH);
RightSizer->Add(sbSizerDisplay, 0, wxEXPAND, BORDER_WIDTH);
sbSizerMsg->Add(m_textCtrl1, 1, wxALL|wxEXPAND, BORDER_WIDTH);
RightSizer->Add(sbSizerMsg, 1, wxTOP|wxEXPAND, BORDER_WIDTH); // truncated
mainSizer->Add(RightSizer, 1, wxLEFT|wxEXPAND, BORDER_WIDTH);
mainPanel->SetSizer(mainSizer);
frameSizer->Add(mainPanel, 1, wxALL|wxEXPAND, BORDER_WIDTH);
SetSizerAndFit(frameSizer);
See screencaptures what I'm having and what I'm expecting, any ideas?

Related

ContentView not updating

I’m somewhat new to Swiftui programming and probably making all kinds of beginner mistakes. That said, I’m trying to learn the language by grinding my teeth on a number of small programs and in this one, can’t seem to get the ContentView to update for numPlayers and numRows when returning from Sheet but the two Bool variables (showRowIndicators and showColumnIndicators) update correctly in ContentView.
Any help would be appreciated! :)
import SwiftUI
struct Player: Identifiable, Hashable {
var id: Int = 0
var name: String = ""
}
struct ContentView: View {
#State var players = [
Player(id: 0, name: "Player1"),
Player(id: 1, name: "Player2"),
Player(id: 2, name: "Player3"),
Player(id: 3, name: "Player4"),
Player(id: 4, name: "Player5"),
Player(id: 5, name: "Player6"),
Player(id: 6, name: "Player7"),
Player(id: 7, name: "Player8"),
Player(id: 8, name: "Player9"),
Player(id: 9, name: "Player10"),
]
#State var numbers = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
]
#AppStorage("numRows") var numRows: Int = 10
#AppStorage("numPlayers") var numPlayers: Int = 4
#AppStorage("showRowIndicators") var showRowIndicators: Bool = false
#AppStorage("showColumnIndicators") var showColumnIndicators: Bool = false
#State var backgroundColor: Color = Color.green
#State var showSheet: Bool = false
var rowOddBColor: Color = Color.white.opacity(0.2)
var rowEvenBColor: Color = Color.green.opacity(0.2)
var maxRows = 20
let boxWidth = 65.0
let boxHeight = 22.0
let boxPadH = 2.0
let HSspace = 7.0
let boxBackColor = Color(#colorLiteral(red: 0.8993894458, green: 0.8753863573, blue: 0.7580057979, alpha: 1))
let boxForeColor = Color(#colorLiteral(red: 0, green: 0, blue: 0, alpha: 1))
let totalBackColor = Color(#colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1))
let topScoreBackColor = Color(#colorLiteral(red: 1, green: 1, blue: 1, alpha: 1))
var winningPlayer: Int = 0
var isTopScore: Int = 0
var body: some View {
ZStack {
//background
backgroundColor
.ignoresSafeArea()
//content
DisplayColumnGuides(numPlayers: $numPlayers, showColumnIndicators: $showColumnIndicators, backgroundColor: $backgroundColor, HSspace: HSspace, boxWidth: boxWidth)
ScrollView(.vertical) {
VStack(spacing: 0) {
HStack {
Image(systemName: "gear")
.font(.largeTitle)
.frame(width: 50, alignment: .leading)
.onTapGesture {
showSheet.toggle()
}
Spacer()
}
DisplayPlayerNames(players: $players, numPlayers: $numPlayers, HSspace: HSspace, boxWidth: boxWidth, boxHeight: boxHeight)
let rowCount: Int = (numRows <= maxRows ? numRows : maxRows)
ForEach(0..<rowCount) { row in
ZStack {
Text("\(row+1)")
.font(.footnote)
.foregroundColor(.white)
.frame(maxWidth: .infinity, alignment: .leading)
HStack(spacing: HSspace) {
ForEach(0..<numPlayers) { column in
TextField("", value: self.$numbers[row][column], format: .number)
.foregroundColor(boxForeColor)
.font(.title3)
.multilineTextAlignment(.center)
.keyboardType(.numbersAndPunctuation)
.frame(width: boxWidth, height: boxHeight)
// .background(boxBackColor)
.cornerRadius(5.0)
// .border(.black, width: 0.2)
}
}
.frame(maxWidth: .infinity)
.frame(height: boxHeight+5)
.background(
showRowIndicators
? ( isNumberEven(number: row)
? rowEvenBColor
: rowOddBColor
)
: nil
)
}
}
VStack(spacing: 10) {
ZStack {
Text("Total")
// .bold()
.font(.footnote)
.foregroundColor(Color.blue)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.top, 5)
HStack(spacing: HSspace) {
ForEach(0..<numPlayers) { player in
let playerScore = addScore(playerNumber: player)
let topPlayer = getTopPlayer()
Text("\(playerScore)")
.font(.title3)
.foregroundColor(boxForeColor)
.bold()
.frame(width: boxWidth, height: boxHeight+5)
.background(topPlayer == player ? topScoreBackColor : totalBackColor)
// .border(.black)
.cornerRadius(10.0)
}
}
.padding(.top, 5)
}
}
Spacer()
}
}
.sheet(isPresented: $showSheet) {
OptionsView()
}
}
.onTapGesture {
//--- Hide Keyboard ---
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
}
.gesture(
DragGesture(minimumDistance: 0, coordinateSpace: .local).onEnded({ gesture in
//--- Hide keyboard on swipe down ---
if gesture.translation.height > 0 {
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
}
}))
}
func isNumberEven(number: Int) -> Bool {
return (number % 2 == 0)
}
func getTopPlayer() -> Int {
var topScore: Int = 0
var topPlayer: Int = -1
for p in 0..<players.count {
let tPlayer = addScore(playerNumber: p)
if tPlayer > topScore {
topScore = tPlayer
topPlayer = p
}
}
return topPlayer
}
func addScore(playerNumber: Int) -> Int {
let rowCount = maxRows
var playerTotal: Int = 0
for row in 0..<rowCount {
playerTotal += numbers[row][playerNumber]
}
return playerTotal
}
}
struct OptionsView: View {
#Environment(\.presentationMode) var presentationMode
#AppStorage("numRows") var numRows: Int?
#AppStorage("numPlayers") var numPlayers: Int = 4
#AppStorage("showRowIndicators") var showRowIndicators: Bool = false
#AppStorage("showColumnIndicators") var showColumnIndicators: Bool = false
var body: some View {
ZStack {
Color.brown.opacity(0.3)
VStack {
Text("Settings")
.font(.largeTitle)
.underline()
.padding(.vertical)
// Button(action: {
// presentationMode.wrappedValue.dismiss()
// }, label: {
// Image(systemName: "xmark")
// .foregroundColor(.red)
// .font(.title)
// .padding(10)
// })
// .frame(maxWidth: .infinity, alignment: .leading)
HStack {
Text("Enter # score rows (max 20)")
.frame(maxWidth: .infinity, alignment: .leading)
Spacer()
TextField("Enter # rows", value: $numRows, format: .number)
.keyboardType(.numberPad)
.multilineTextAlignment(.center)
.frame(width: 100)
.background(Color.white)
.cornerRadius(10.0)
}
.padding(.horizontal)
HStack {
Text("Enter # players (max 10)")
.frame(maxWidth: .infinity, alignment: .leading)
Spacer()
TextField("Enter # players", value: $numPlayers, format: .number)
.keyboardType(.numberPad)
.multilineTextAlignment(.center)
.frame(width: 100, alignment: .center)
.background(Color.white)
.cornerRadius(10.0)
}
.padding(.horizontal)
Toggle(isOn: $showRowIndicators, label: {
Text("Show row guides")
})
.padding(.horizontal)
.padding(.top, 20)
Toggle(isOn: $showColumnIndicators, label: {
Text("Show column guides")
})
.padding(.horizontal)
.padding(.top, 5)
Button(action: {
presentationMode.wrappedValue.dismiss()
}, label: {
Text("Close")
.foregroundColor(.blue)
.font(.title)
.frame(width: 100, height: 40.0)
.background(Color.white)
.cornerRadius(25)
.padding(10)
})
.padding(.top, 40)
Spacer()
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
// OptionsView()
}
}
struct DisplayColumnGuides: View {
#Binding var numPlayers: Int
#Binding var showColumnIndicators: Bool
#Binding var backgroundColor: Color
var HSspace: Double
var boxWidth: Double
var body: some View {
HStack(spacing: HSspace) {
ForEach(0..<numPlayers) { player in
Rectangle()
.fill(
showColumnIndicators
? Color.blue.opacity(0.2)
: backgroundColor
)
.frame(width: boxWidth, alignment: .center)
}
}
.padding(.vertical, 5)
}
}
struct DisplayPlayerNames: View {
#Binding var players: [Player]
#Binding var numPlayers: Int
var HSspace: Double
var boxWidth: Double
var boxHeight: Double
var body: some View {
HStack(spacing: HSspace) {
ForEach(0..<numPlayers) { player in
TextField("", text: self.$players[player].name)
// .underline()
.multilineTextAlignment(.center)
.frame(width: boxWidth, height: boxHeight, alignment: .center)
}
}
.padding(.vertical, 5)
}
}

why does model.predict in tensorflowjs keeps returning the same incorrect output regardless of the tensor given?

I'm trying to get a keras model i converted to tensorflow js, to work in react native but the model keeps giving bad responses. Did some digging and found realized that the tensor i passed into model.predict is some how being changed causing it to give the same incorrect prediction. Any suggestions would be appreciated. I'm pretty much hard stuck. Code below:
import React, {useState, useEffect} from 'react';
import {View, Text, Button} from 'react-native';
import * as tf from '#tensorflow/tfjs';
import {
bundleResourceIO
} from '#tensorflow/tfjs-react-native';
import * as mobilenet from '#tensorflow-models/mobilenet';
function thing() {
const [model, setModel] = useState(null);
const [tensor, setTensor] = useState(null);
async function loadModel() {
const modelJson = require('./assets/model.json');
const weight = require('./assets/group1-shard1of1.bin');
const backend = await tf.ready();
const item = await tf.loadLayersModel(
bundleResourceIO(modelJson, weight)
);
const tfTensor = tf.tensor([[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]);
setModel(item);
setTensor(tfTensor);
}
useEffect(() => {
loadModel();
}, []);
async function test() {
if(tensor !== null && model !== null) {
const result = await model.predict(tensor);
console.log(result.dataSync())
}
}
return (
<View>
<Button
onPress={test}
title="click"
color="#841584"
accessibilityLabel="Learn more about this purple button"
/>
</View>
);
}
export default thing;
Just like changing a single pixel in an image doesn't change the image, changing one bit in an array doesn't significantly adjust the prediction.
I ran mobilenet on a black 224x224 image and it predicted class 819 (whatever that is). Then I changed the top-left pixel to white and re-ran mobilenet and it still classifies as class 819.
See example code here
Changing a single bit does not have a cascading effect like a hash function. Mobilenet, by its nature is resilient to noise.

Arduino LED Cube 4x4x4 Any Ideas how to Fix

// Connections
int mreset = 10;
int shift = 11;
int store = 12;
int data = 13;
int taster = 9;
int a, tasterstatus = 0;
// Delays
int tasterdelay = 250;
int fast = 5;
int stage1 = 1000;
int stage2 = 1000;
unsigned long time_now = 0;
// Pattern
int firstlevel[24] = {1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0};
int secondlevel[24] = {0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0};
int thirdlevel[24] = {0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0};
int fourthlevel[24] = {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0};
int leftside[24] = {1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int ndleftside[24] = {1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int ndrightside[24] = {1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0};
int rightside[24] = {1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0};
int backside[24] = {1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0};
int ndbackside[24] = {1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0};
int ndfrontside[24] = {1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0};
int frontside[24] = {1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0};
int cube1[24] = {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int cube2_1[24] = {1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int cube2_2[24] = {0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int bigcube1_1[24] = {1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0};
int bigcube1_2[24] = {0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0};
int cube3_1[24] = {0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0};
int cube3_2[24] = {0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0};
int cube4[24] = {0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0};
int cube5_1[24] = {1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0};
int cube5_2[24] = {0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0};
int cube6[24] = {1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int cube7_1[24] = {0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0};
int cube7_2[24] = {0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0};
int cube8[24] = {0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0};
int custom1[24] = {1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0};
int custom2[24] = {0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0};
void setup() {
//Set Outputs
pinMode(shift , OUTPUT);
pinMode(store , OUTPUT);
pinMode(data , OUTPUT);
pinMode(mreset , OUTPUT);
pinMode(taster , INPUT);
// Set Shift Register Master Reset On/Off
digitalWrite(mreset, LOW);
digitalWrite(store, HIGH);
digitalWrite(mreset, HIGH);
digitalWrite(store, LOW);
}
void loop() {
//Waiting for Button PRess
tasterstatus = digitalRead(taster);
if (tasterstatus == HIGH) {
a++;
delay(tasterdelay);
}
//Choose Pattern
if (a == 1) {
pattern1();
}
if (a == 2) {
pattern2();
}
}
void pattern1() {
//Equate Millis with time_now
time_now = millis();
// First Sample for LED Cube
for (int i = 0; i < 24; i++) {
digitalWrite(shift, LOW);
digitalWrite(data, firstlevel[i]);
digitalWrite(shift, HIGH);
}
digitalWrite(store, HIGH);
digitalWrite(store, LOW);
// "Delay"
while (millis() < time_now + stage1) {
tasterstatus = digitalRead(taster);
// Checking Button State
if (tasterstatus == HIGH) {
delay(tasterdelay);
a++;
pattern2();
}
}
// Clearing Shift Registers with Master Reset
digitalWrite(mreset, LOW);
digitalWrite(store, HIGH);
digitalWrite(mreset, HIGH);
digitalWrite(store, LOW);
time_now = millis();
for (int i = 0; i < 24; i++) {
digitalWrite(shift, LOW);
digitalWrite(data, secondlevel[i]);
digitalWrite(shift, HIGH);
}
digitalWrite(store, HIGH);
digitalWrite(store, LOW);
while (millis() < time_now + stage1) {
tasterstatus = digitalRead(taster);
if (tasterstatus == HIGH) {
delay(tasterdelay);
a++;
pattern2();
}
}
digitalWrite(mreset, LOW);
digitalWrite(store, HIGH);
digitalWrite(mreset, HIGH);
digitalWrite(store, LOW);
time_now = millis();
for (int i = 0; i < 24; i++) {
digitalWrite(shift, LOW);
digitalWrite(data, thirdlevel[i]);
digitalWrite(shift, HIGH);
}
digitalWrite(store, HIGH);
digitalWrite(store, LOW);
while (millis() < time_now + stage1) {
tasterstatus = digitalRead(taster);
if (tasterstatus == HIGH) {
delay(tasterdelay);
a++;
pattern2();
}
}
digitalWrite(mreset, LOW);
digitalWrite(store, HIGH);
digitalWrite(mreset, HIGH);
digitalWrite(store, LOW);
time_now = millis();
for (int i = 0; i < 24; i++) {
digitalWrite(shift, LOW);
digitalWrite(data, fourthlevel[i]);
digitalWrite(shift, HIGH);
}
digitalWrite(store, HIGH);
digitalWrite(store, LOW);
while (millis() < time_now + stage1) {
tasterstatus = digitalRead(taster);
if (tasterstatus == HIGH) {
delay(tasterdelay);
a++;
pattern2();
}
}
digitalWrite(mreset, LOW);
digitalWrite(store, HIGH);
digitalWrite(mreset, HIGH);
digitalWrite(store, LOW);
}
void pattern2() {
time_now = millis();
for (int i = 0; i < 24; i++) {
digitalWrite(shift, LOW);
digitalWrite(data, cube1[i]);
digitalWrite(shift, HIGH);
}
digitalWrite(store, HIGH);
digitalWrite(store, LOW);
}`enter code here
My Problem Is that when i press the button in Pattern1, Pattern2 Starts 1x time, after that Pattern1 continues where i pressed the Button, runs 1x trough, and after that pattern 2 repeats normaly. Any ideas how to fix it ? Like when i press the Button First Pattern1 repeats infinity as it should. But when i press it again, while Pattern1 is running, its goes to Pattern2 as it should, but it only repeats Pattern2 1x time, than it resumes pattern1, where i pressed the button, and then it repeats pattern2 as it should.
So the Main Problem is that Pattern1 Runs 1x time in pattern2;
Thanks for help
i fixed it by putting a return; after pattern()2; ;)

Two Material Circular Mesh - Gmsh

I have the following .geo for GMSH:
cl__1 = 1.125;
Point(1) = {0, 0, 0, cl__1};
Point(2) = {1, 0, 0, cl__1};
Point(3) = {1, 1, 0, cl__1};
Point(4) = {0, 1, 0, cl__1};
Point(5) = {0.350000,0.100000,cl__1};
Point(6) = {0.350000,0.350000,cl__1};
Point(7) = {0.100000,0.350000,cl__1};
Point(8) = {0.85,0.85,cl__1};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Circle(5) = {5,6,7};
Line(6) = {7,8};
Line(7) = {8,5};
Line Loop(1) = {1, 2, 3, 4};
Line Loop(2) = {5,6,7};
Plane Surface(1) = {1,2};
Plane Surface(2) = {2};
Circle {5} In Surface {2};
Line {6} In Surface {2};
Line {7} In Surface {2};
I have drawn exactly the geometry I want to build but somehow Gmsh is only meshing inside Plane Surface 2.
Is there anything wrong in this code?
The point definition for points 5 - 8 are not in plane z = 0 they are in plane (z = cl_1). A suggestion, when you write this kind of files try to arrange things in the following way:
cl_1 = 1.125;
Point(1) = {0 , 0 , 0, cl_1};
Point(2) = {1 , 0 , 0, cl_1};
Point(3) = {1 , 1 , 0, cl_1};
Point(4) = {0 , 1 , 0, cl_1};
Point(5) = {0.350000, 0.100000, 0, cl_1};
Point(6) = {0.350000, 0.350000, 0, cl_1};
Point(7) = {0.100000, 0.350000, 0, cl_1};
Point(8) = {0.85 , 0.85 , 0, cl_1};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Circle(5) = {5,6,7};
Line(6) = {7,8};
Line(7) = {8,5};
Line Loop(1) = {1, 2, 3, 4};
Line Loop(2) = {5,6,7};
Plane Surface(8) = {1, 2};
Plane Surface(9) = {2};
you can save lot of time only by inspection.

Google Maps LocalSearch API custom marker not showing

I have implemented the LocalSearch API (GSmapSearchControl) which is working nicely.
I simply want to change the default green pin marker to my own custom marker.
My code runs through successfully (no javascript errors), the image URLs definitely exist, yet the custom marker doesn't display. No errors, but I just still get the default green pin marker.
Any ideas??
<script type="text/javascript">
function load() {
var container = document.getElementById("mapsearch");
new GSmapSearchControl(container, "4 Dan Close Lambton",
{ title: "Dan Close",
url: "<%=Model.ToFullUrl() %>",
idleMapZoom: GSmapSearchControl.ACTIVE_MAP_ZOOM + 3,
hotspots: hotspots,
showResultList: GSmapSearchControl.DEFAULT_RESULT_LIST,
drivingDirections: GSmapSearchControl.DRIVING_DIRECTIONS_FROM_USER,
linkTarget: GSearch.LINK_TARGET_BLANK,
onBootComplete: bootComplete
}
);
}
GSearch.setOnLoadCallback(load);
function bootComplete(searchControl) {
var image = new google.maps.MarkerImage('http://localhost:59825/images/markers/image.png', new google.maps.Size(16, 16), new google.maps.Point(0, 0), new google.maps.Point(8, 16));
var shadow = new google.maps.MarkerImage('http://localhost:59825/images/markers/shadow.png', new google.maps.Size(28, 16), new google.maps.Point(0, 0), new google.maps.Point(8, 16));
var shape = { coord: [15, 0, 15, 1, 15, 2, 15, 3, 15, 4, 15, 5, 15, 6, 15, 7, 15, 8, 15, 9, 15, 10, 15, 11, 15, 12, 15, 13, 15, 14, 15, 15, 0, 15, 0, 14, 0, 13, 0, 12, 0, 11, 0, 10, 0, 9, 0, 8, 0, 7, 0, 6, 0, 5, 0, 4, 0, 3, 0, 2, 0, 1, 0, 0, 15, 0], type: 'poly' };
var point = new google.maps.LatLng(-32.916792, 151.708295);
var marker = new google.maps.Marker({ draggable: false, position: point, shadow: shadow, icon: image, shape: shape });
localSearch.idleMarker = marker;
localSearch.mapCenterMarker = marker;
}